เพื่อ Zoom ด้วย Axes3D
- ตั้งค่าขนาดรูปและ padding ระหว่าง subplots
- สร้าง figure ใหม่หรือเปิดใช้งาน figure ที่มีอยู่ด้วย figure()
- ดึงออบเจ็กต์ 3D axes ด้วย Axes3D(fig)
- พลอต x, y, z ด้วย scatter()
- แสดงรูปด้วย show() (สามารถ zoom/rotate ได้แบบโต้ตอบ)
ตัวอย่าง
from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = Axes3D(fig) x = [2, 4, 6, 3, 1] y = [1, 6, 8, 1, 3] z = [3, 4, 10, 3, 1] ax.scatter3D(x, y, z, c=z, alpha=1, marker='d', s=150) plt.show()
ผลลัพธ์
