반응형

/*******************************************************************************************************************
-- Title : [Py3.5] 3D Wireframe and Scatter Plot w/ Matplotlib
-- Reference : pythonprogramming.net
-- Key word : matplotlib axes3d pyplot plot_wireframe wireframe 3d graph 그래프 scatter
*******************************************************************************************************************/

-- 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import style
 
# ------------------------------
# -- Wireframe 3D Chart
# ------------------------------
# -- 차트 스타일 설정
style.use('fivethirtyeight')
 
# --axes3d를 활용한 3D 그래프
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
 
# -- 데이터셋
= [12345678910]
= [5678256372]
= [1263273372]
 
# -- wireframe 선언
ax1.plot_wireframe(x, y, z)
 
# -- 라벨 표시
ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')
 
# -- Show
plt.show()
 
# ------------------------------
# -- Scatter 3D Chart
# ------------------------------
# -- 차트 스타일 설정
style.use('ggplot')
 
# --axes3d를 활용한 3D 그래프
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
 
# -- 데이터셋
= [1,2,3,4,5,6,7,8,9,10]
= [5,6,7,8,2,5,6,3,7,2]
= [1,2,6,3,2,7,3,3,7,2]
 
x2 = [-1,-2,-3,-4,-5,-6,-7,-8,-9,-10]
y2 = [-5,-6,-7,-8,-2,-5,-6,-3,-7,-2]
z2 = [1,2,6,3,2,7,3,3,7,2]
 
# -- scatter 그래프 선언
ax1.scatter(x, y, z, c='g', marker='o')
ax1.scatter(x2, y2, z2, c ='r', marker='o')
 
# -- 라벨 표시
ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')
 
# -- Show
plt.show()
 
 
# ------------------------------
# -- Wireframe 3D Chart-2
# ------------------------------
import numpy as np
 
# -- 차트 스타일 설정
style.use('ggplot')
 
# --axes3d를 활용한 3D 그래프
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
 
# -- 테스트 데이터 확인/입력
print (axes3d.get_test_data())
x, y, z = axes3d.get_test_data()
 
# -- wireframe 선언
print(axes3d.__file__)
ax1.plot_wireframe(x,y,z, rstride = 3, cstride = 3)
 
ax1.set_xlabel('x axis')
ax1.set_ylabel('y axis')
ax1.set_zlabel('z axis')
 
# -- Show
plt.show()
 
 

cs

반응형

+ Recent posts