简体   繁体   English

重新定向 Matplotlib 极性 plot

[英]Reorient Matplotlib polar plot

I would like to produce a polar scatterplot in matplotlib.我想在 matplotlib 中生成一个极坐标散点图。 The plot I have from using ax1 = plt.subplot(111, polar=True) looks fine, but I need to deviate from the usual polar graph orientation.我使用ax1 = plt.subplot(111, polar=True)的 plot 看起来不错,但我需要偏离通常的极坐标图方向。

  1. I need 0 degrees to point straight up (rotation).我需要 0 度来直指(旋转)。
  2. I need 90 degrees to point right (mirror image).我需要 90 度指向右侧(镜像)。

(How) Can I do this? (我怎样才能做到这一点?

You need ax.set_theta_zero_location and ax.set_theta_direction .您需要ax.set_theta_zero_locationax.set_theta_direction For details, see the doc有关详细信息,请参阅文档

import matplotlib.pyplot as plt
import numpy as np


r = range(360)
angles = [i * np.pi / 180 for i in r]

f = plt.figure()
ax = plt.subplot(polar=True)
plt.polar(angles, r)

ax.set_xticks(angles[::10])
ax.set_theta_zero_location("N")
ax.set_theta_direction(-1)

plt.show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM