<*Matplotlib 3차원 산점도 그리기 *>
◆ matplotlib.pyplot 모듈의 scatter() 함수를 이용해서 3차원 산점도 (3D Scatter plot)를 그리는 방법.
---< 예제 : Scatter-3D.py 3차원 산점도 그리기 >---------------------------------------
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
n = 100
xmin, xmax, ymin, ymax, zmin, zmax = 0, 20, 0, 20, 0, 50
cmin, cmax = 0, 2
xs = np.array([(xmax - xmin) * np.random.random_sample() + xmin for i in range(n)])
ys = np.array([(ymax - ymin) * np.random.random_sample() + ymin for i in range(n)])
zs = np.array([(zmax - zmin) * np.random.random_sample() + zmin for i in range(n)])
color = np.array([(cmax - cmin) * np.random.random_sample() + cmin for i in range(n)])
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111, projection='3d')
ax.scatter(xs, ys, zs, c=color, marker='o', s=15, cmap='Greens')
plt.show()
______________________________________________________________________________________
▶ 임의로 생성된 100개의 x, y, z 값 데이터를 3차원 산점도로 나타낸다.