将python windrose绘图导出为eps

2024-04-28 05:58:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我用windrose模块https://windrose.readthedocs.io/en/latest/index.html绘制了我的风数据(方向和速度)。 结果看起来很不错,但我不能将它们导出为图形(png、eps或任何开头的内容),因为结果是一个没有“savefig”属性的特殊对象类型,或者我找不到它。在

我有两个pandas.core.系列.系列:ff、dd

 print(ff)

结果:

^{pr2}$

结果:

TIMESTAMP
2016-08-01 00:00:00    328.80
2016-08-01 01:00:00    299.60
2016-08-01 02:00:00    306.90  
2016-08-01 03:00:00    288.60
...

我的代码看起来像:

from windrose import WindroseAxes

ax2 = WindroseAxes.from_ax()
ax2.bar(dd, ff, normed=True, opening=0.8, edgecolor='white', bins = [0,4,11,17])
ax2.set_legend()
ax2.tick_params(labelsize=18)
ax2.set_legend(loc='center', bbox_to_anchor=(0.05, 0.005), fontsize = 18)
ax2.savefig('./figures/windrose.eps')
ax2.savefig('./figures/windrose.png')

但结果是:

AttributeError: 'WindroseAxes' object has no attribute 'savefig'

你知道如何从结果中得出一个结果,这样我就可以在工作中使用它了吗?在

谢谢!在


Tags: 模块fromhttpspngreadthedocsepsddff
1条回答
网友
1楼 · 发布于 2024-04-28 05:58:36

发生错误是因为您试图保存子图而不是图形。尝试:

 fig,ax2 = plt.subplots(1,1) # Or whatever you need.
 # The windrose code you showed
 fig.savefig('./figures/windrose.png')

相关问题 更多 >