Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Vẽ biểu đồ cực (polar) nửa hoặc tư phần trong Matplotlib

Để giới hạn góc hiển thị của polar plot (nửa vòng hoặc 1/4 vòng), dùng ax.set_thetamax().

Các bước

  • Thiết lập figure size và autolayout.
  • Tạo figure và axes polar: add_subplot(111, projection="polar").
  • Đặt góc tối đa: ax.set_thetamax(90) (90° = 1/4 vòng, 180° = nửa vòng).
  • Hiển thị bằng show().

Ví dụ

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()

Kết quả

Vẽ biểu đồ cực (polar) nửa hoặc tư phần trong Matplotlib