【发布时间】:2020-07-19 00:46:42
【问题描述】:
我想在 matplotlib 中生成一个极坐标散点图。我使用ax1 = plt.subplot(111, polar=True) 得到的图看起来不错,但我需要偏离通常的极坐标图方向。
- 我需要 0 度才能指向正上方(旋转)。
- 我需要 90 度指向右侧(镜像)。
(如何)我可以这样做吗?
【问题讨论】:
标签: python matplotlib plot scatter-plot polar-coordinates
我想在 matplotlib 中生成一个极坐标散点图。我使用ax1 = plt.subplot(111, polar=True) 得到的图看起来不错,但我需要偏离通常的极坐标图方向。
(如何)我可以这样做吗?
【问题讨论】:
标签: python matplotlib plot scatter-plot polar-coordinates
您需要ax.set_theta_zero_location 和ax.set_theta_direction。
详情见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()
【讨论】: