我正在尝试创建一个并排有两朵风玫瑰的人物,但它一直KeyError: 'theta_labels'在第 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