自学Python问题记录2:解决画风玫瑰图出现报错No artists with labels found to put in legend.

报错情况

No artists with labels found to put in legend. Note that artists whose label start with an underscore are ignored when legend() is called with no argument.

原因

#legend相关代码中缺乏label名称的说明,需要给予图例对应的名字
plt.legend(loc=4, bbox_to_anchor=(1.15, -0.07))#原代码报错并不显示图例
plt.legend(loc=4, bbox_to_anchor=(1.15, -0.07),labels=['频次']) # 调整后不报错并显示图例

你可能感兴趣的:(python报错解决,python,开发语言)