matplotlib极地散射图:如何将单位更改为除度数之外的任何值?

时间:2018-05-15 13:57:55

标签: python matplotlib

在matplotlib极坐标散点图中,如何将 theta 轴的单位从角度更改为任意指定的单位?

https://matplotlib.org/gallery/pie_and_polar_charts/polar_scatter.html开始(所有示例都以度为单位),

import numpy as np
import matplotlib.pyplot as plt

# Fixing random state for reproducibility
np.random.seed(19680801)

# Compute areas and colors
N = 150
r = 2 * np.random.rand(N)
theta = 2 * np.pi * np.random.rand(N)
area = 200 * r**2
colors = theta

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
c = ax.scatter(theta, r, c=colors, s=area, cmap='hsv', alpha=0.75)
plt.show()

theta轴始终为度。对于给定的函数degrees=days2degrees(days),如果我想要它,比如几天,该怎么办?我应该使用

ax.set_thetalim()
ax.set_thetamin()
ax.set_thetamax()

等?这些似乎需要输入

1 个答案:

答案 0 :(得分:1)

不确定这会回答你的问题:

只需添加类似

的内容
t = ax.get_xticks()
# your function
days = t/(2 * np.pi)  * 365
ax.set_xticklabels(days, fontsize=12)