如何制作很多风玫瑰?

2024-04-28 06:05:37 发布

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

我试图创建一个两朵风玫瑰并排的图形,但它一直在第18行返回给我

这是我的密码:

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

#### ---------------- 

def set_legend(ax):
    l = ax.legend(loc="center right",borderaxespad=-1)
    # l.get_frame().set_fill(False) #transparent legend
    plt.setp(l.get_texts(), fontsize=10,weight='bold')

fig=plt.figure(figsize=(15,15))
left_rectangle = [0, 0.1, 0.4, 0.75] #[left, bottom, width, height] as a fraction of total figure size
right_rectangle = [0.5, 0.1, 0.4, 0.75] #[left, bottom, width, height] as a fraction of total figure size
ax1 = WindroseAxes(fig, left_rectangle)
ax2 = WindroseAxes(fig, right_rectangle)


fig.add_axes(ax1)
ax1.bar(DIRECTIONDATA1,DATA1, normed=True, opening=0.6, bins = np.arange(0, 6, 1),edgecolor='grey', nsector=8, cmap=cm.viridis_r)
ax1.grid(True,linewidth=1.5,linestyle='dotted')
set_legend(ax1)


fig.add_axes(ax2)
ax2.bar(np.array(DIRECTIONDATA2),np.array(DATA2), normed=True, opening=0.6, bins = np.arange(0, 6, 1),edgecolor='grey', nsector=8, cmap=cm.viridis_r)
ax2.grid(True,linewidth=1.5,linestyle='dotted')
set_legend(ax2)

我使用的是下面的风玫瑰:https://github.com/python-windrose/windrose/tree/master/windrose


Tags: importrighttrueasnpfigpltleft