반응형
/*******************************************************************************************************************
-- Title : [Py3.5] 3D Bar Plot w/ Matplotlib
-- Reference : pythonprogramming.net
-- Key word : matplotlib axes3d pyplot bar3d 3d graph 그래프
*******************************************************************************************************************/
-- Figure
-- Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt import numpy as np from matplotlib import style # -- 차트 스타일 설정 style.use('ggplot') # --axes3d를 활용한 3D 그래프 fig = plt.figure() ax1 = fig.add_subplot(111, projection='3d') # -- 데이터셋 x3 = [1,2,3,4,5,6,7,8,9,10] y3 = [5,6,7,8,2,5,6,3,7,2] z3 = np.zeros(10) print (z3) # [ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.] dx = np.ones(10) dy = np.ones(10) dz = [1,2,3,4,5,6,7,8,9,10] print (dx) # [ 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] print (dy) # [ 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] # -- Bar 3D 그래프 선언 ax1.bar3d(x3, y3, z3, dx, dy, dz) ax1.set_xlabel('x axis') ax1.set_ylabel('y axis') ax1.set_zlabel('z axis') # -- Show plt.show() | cs |
반응형