Để vẽ scatter 3D không hiển thị trục, ta dùng scatter() và tắt axes bằng ax.axis('off').
Các bước thực hiện
- Thiết lập kích thước hình và khoảng đệm.
- Tạo hình bằng figure().
- Thêm axes 3D như subplot.
- Tạo xs, ys, zs ngẫu nhiên bằng NumPy.
- Vẽ scatter bằng scatter() với colormap.
- Tắt trục bằng ax.axis('off').
- Hiển thị bằng show().
Ví dụ
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig = plt.figure()
ax = fig.add_subplot(projection="3d")
xs = np.random.rand(100)
ys = np.random.rand(100)
zs = np.random.rand(100)
ax.scatter(xs, ys, zs, c=xs, cmap="copper")
ax.axis('off')
plt.show()
Kết quả
