ใช้ ax.scatter() บน axes 3D แล้วปิดแกนและกริดทั้งหมดด้วย ax.axis('off') ได้ scatter 3D แบบ minimalist สะอาดตา
ขั้นตอนการทำงาน
- ตั้งค่าขนาดรูปและเลย์เอาต์
- สร้าง figure และ axes 3D
- สร้างข้อมูล xs, ys, zs แบบสุ่ม
- พลอต scatter 3D ด้วย
ax.scatter()กำหนด colormap - ปิดแกนด้วย
ax.axis('off') - แสดงผล
ตัวอย่างโค้ด
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()
ผลลัพธ์
