Scatter plot 3D hiển thị phân bố điểm trong không gian 3 chiều (x, y, z).
Cài đặt
pip install matplotlib
Ví dụ: Đường xoắn ốc 3D
from mpl_toolkits import mplot3d
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = plt.axes(projection='3d')
z = np.linspace(0, 1, 100)
x = z * np.sin(20 * z)
y = z * np.cos(20 * z)
ax.scatter(x, y, z, c='blue')
ax.set_xlabel('X-axis')
ax.set_ylabel('Y-axis')
ax.set_zlabel('Z-axis')
ax.set_title('3D Scatter Plot')
plt.show()
Kết quả

Giải thích
- Tạo đường cong tham số: x=z·sin(20z), y=z·cos(20z).
scattervẽ điểm, màu xanh.- Phù hợp cho dữ liệu điểm mây, phân cụm 3D.