为了账号安全,请及时绑定邮箱和手机立即绑定

python画风玫瑰图出现attributeerror:unknown property axisbg错误

python画风玫瑰图出现attributeerror:unknown property axisbg错误

# -- coding: utf-8 --import xlrdimport xlrdimport matplotlib as mplimport matplotlib.cm as cmfrom matplotlib import pyplot as pltfrom windrose import WindroseAxesfrom numpy.random import randomfrom datetime import datetimempl.rcParams['font.sans-serif'] = ['SimHei']  #指定默认字体 #画风向风速玫瑰图ws = random(500) * 6wd = random(500) * 360def new_axes():   #定义函数    fig = plt.figure(figsize=(8, 8), dpi=80, facecolor='w', edgecolor='w')    rect = [0, 0, 1, 1]    ax = WindroseAxes(fig, rect, axisbg='w')    fig.add_axes(ax)    return ax#...and adjust the legend box#标签图例def set_legend(ax):    l = ax.legend(shadow=False, bbox_to_anchor=[1, 0])    plt.setp(l.get_texts(), fontsize=12)#读取数据#for sn in range(2):     #2个sheet中都有数据,一次绘制多个风玫瑰图 #workspace=(r"……工作空间")mybook=xlrd.open_workbook(r'fxfs.xlsx')#打开文件mysheet=mybook.sheet_by_index(0)rows=mysheet.nrowsws=mysheet.col_values(5)   #风向wd=mysheet.col_values(6)   #风速ws.pop(0)ws.pop(0)wd.pop(0)wd.pop(0)    sl=[0,0.2,1.5,3.3,5.4,7.9]     #风速重分类间断点  ax=new_axes()#ax.bar(wd, ws, normed=True, opening=0.8, edgecolor='white')ax.contourf(wd,ws,bins=sl,normed=True,cmap=cm.cool) #使用matplotlib内置colormap进行色彩分割ax.set_title(mysheet.name,fontsize=15,loc='right')set_legend(ax)plt.show()输出错误如图
查看完整描述

1 回答

?
大泽九章

TA贡献1条经验 获得超0个赞

该方法已经被取消了,现在用facecolor = color来实现
查看完整回答
反对 回复 2018-09-06
  • 1 回答
  • 0 关注
  • 6253 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信