ตั้งค่าช่วงแกน x, y, z ในกราฟ 3D
ใช้ set_xlim3d, set_ylim3d, set_zlim3d
ขั้นตอน
- สร้าง figure ด้วย figure()
- สร้าง axes 3D ด้วย Axes3D()
- ปรับแกน X ด้วย set_xlim3d()
- ปรับแกน Y ด้วย set_ylim3d()
- ปรับแกน Z ด้วย set_zlim3d()
- แสดงด้วย show()
ตัวอย่างโค้ด
from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = Axes3D(fig) ax.set_xlim3d(-100, 100) ax.set_ylim3d(-100, 100) ax.set_zlim3d(-100, 100) plt.show()
ผลลัพธ์
