我试图在 python 中比较风玫瑰,但这很困难,因为我无法弄清楚如何在所有地块上制作相同的比例。其他人在这里问了同样的问题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()
Run Code Online (Sandbox Code Playgroud)
下面的 bin_range 设置条形比例,但我需要更改 y 轴频率比例,以便可以将其与具有不同数据的其他风玫瑰进行比较。
ax.bar(wind_dir,wind_sd,normed=True,bins=bins_range)
Run Code Online (Sandbox Code Playgroud)
这个 set_ylim 似乎确实有效,但 yaxis 刻度不会改变
ax.set_ylim(0,50)
Run Code Online (Sandbox Code Playgroud)
下面的这个 set_ticks 行没有做任何事情,我不知道为什么
ax.yaxis.set_ticks(np.arange(0,50,10))
ax.set_legend()
plt.show()
Run Code Online (Sandbox Code Playgroud) 我不明白为什么我的文字标题没有出现在我的绘图上。我发现文档中关于图例和标题标签的放置顺序非常混乱。
我的代码在这里,我不知道出了什么问题。除了标题的文本根本没有,一切都按我期望的显示(标题,轴标签,日期格式等)。
fig = plt.figure(figsize=(24, 12), dpi=60)
ax = fig.add_subplot(111)
plt.plot(datetime_series,ws_cumsum_mean1,label='1979-1994')
plt.plot(datetime_series,ws_cumsum_mean2,label='1996-2005')
plt.plot(datetime_series,ws_cumsum_mean3,label='2006-2014')
txt = '''Caption text'''
plt.legend(loc='best')
Run Code Online (Sandbox Code Playgroud)
这是我尝试添加标题的地方:
ax.text(0.5,-0.5,txt,transform=ax.transAxes)
Run Code Online (Sandbox Code Playgroud)
。
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%d-%m'))
plt.ylabel('Y label title')
plt.xlabel('X label title')
plt.title('Plot title')
Run Code Online (Sandbox Code Playgroud)