Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีพล็อตกราฟ Polar แบบครึ่งวงกลมหรือสี่ส่วนใน Matplotlib


ขั้นตอนการทำงาน

  • กำหนดขนาดรูปภาพและปรับระยะห่างระหว่างและรอบๆ subplots
  • สร้าง figure ใหม่หรือเปิดใช้งาน figure ที่มีอยู่ด้วย figure()
  • เพิ่ม axes เข้าไปใน figure เป็นส่วนหนึ่งของ subplot arrangement
  • สำหรับกราฟ polar ครึ่งวงกลมหรือสี่ส่วน ใช้ set_thetamax()
  • ใช้เมธอด show() เพื่อแสดงรูปภาพ

ตัวอย่างโค้ด

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(111, projection="polar")
max_theta = 90
ax.set_thetamax(max_theta)
plt.show()

ผลลัพธ์

วิธีพล็อตกราฟ Polar แบบครึ่งวงกลมหรือสี่ส่วนใน Matplotlib