如何制作风玫瑰的子图?

时间:2020-04-23 20:20:06

标签: python matplotlib

我正在尝试创建一个并排放置两个风玫瑰的图形,但是它总是在第18行返回我KeyError: 'theta_labels'

这是我的代码:

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

0 个答案:

没有答案