风玫瑰蟒蛇的自定义缩放

时间:2018-06-12 15:59:57

标签: python matplotlib polar-coordinates

我正在尝试比较python中的风玫瑰,但这很难,因为我无法弄清楚如何在所有情节中制作相同的比例。有人在这里问了同样的问题Custom percentage scale used by windrose.py,但没有回答。

示例代码:

from windrose import WindroseAxes
import numpy as np
import matplotlib.pyplot as plt

wind_dir = np.array([30,45,90,43,180])
wind_sd = np.arange(1,wind_dir.shape[0]+1)
bins_range = np.arange(1,6,1) # this sets the legend scale
fig,ax = plt.subplots()
ax = WindroseAxes.from_ax()
下面的 bin_range设置了条形比例,但是我需要更改y轴频率比例,以便可以将其与其他具有不同数据的风玫瑰进行比较。

ax.bar(wind_dir,wind_sd,normed=True,bins=bins_range) 

这个set_ylim似乎确实有效,但yaxis滴答不会改变

ax.set_ylim(0,50)

下面的set_ticks行没有做任何事情,我不知道为什么

ax.yaxis.set_ticks(np.arange(0,50,10))

ax.set_legend()
plt.show()

1 个答案:

答案 0 :(得分:1)

from windrose import WindroseAxes
import numpy as np
import matplotlib.pyplot as plt

wind_dir = np.array([30,45,90,43,180])
wind_sd = np.arange(1,wind_dir.shape[0]+1)
bins_range = np.arange(1,6,1) # this sets the legend scale

ax = WindroseAxes.from_ax()
ax.bar(wind_dir,wind_sd,normed=True,bins=bins_range)
ax.set_yticks(np.arange(10, 60, step=10))
ax.set_yticklabels(np.arange(10, 60, step=10))
plt.show()

enter image description here

相关问题