风向玫瑰图和污染物玫瑰图是很漂亮的数据可视化展现方式,我们今天花点时间来进行一下实践。
我们先不使用第三方包来进行绘制,具体如下:
def simplePloter():
'''
不适用包,简单绘制
'''
N=100
theta=np.linspace(0.0,2*np.pi,N,endpoint=False)
radii=10*np.random.rand(N)
width=np.pi/4*np.random.rand(N)
ax=plt.subplot(111, projection='polar')
bars=ax.bar(theta,radii,width=width,bottom=0.0)
for r, bar in zip(radii,bars):
bar.set_facecolor(plt.cm.jet(r/10.))
bar.set_alpha(0.8)
plt.savefig('simplePloter_windrose.png')
plt.show()
结果如下:
调整N值变小如下:
可以看出来还是很漂亮的哈,网上已经有开源的模块windrose可以很方便地实现玫瑰图的绘制,这里我们也来使用一下,GitHub地址在这里,最新的文档在这里,官网中展示了很