指定 matplotlib 图例字体粗细的最佳方法是什么?我可以用:
matplotlib.rcParams.update({'legend.fontsize':12})
设置字体大小,但是当我使用
matplotlib.rcParams.update({'legend.fontweight':'bold'
}
它抱怨“‘legend.fontweight’不是有效的 rc 参数”
您可以将参数传递到plt.legend
使用prop争论 http://matplotlib.org/api/legend_api.html#matplotlib.legend.Legend。该词典允许您选择文本属性 http://matplotlib.org/users/text_props.html#text-properties-and-layout为了传奇。
import matplotlib
import matplotlib.pyplot as plt
legend_properties = {'weight':'bold'}
plt.plot([1,2,3], [4,5,6], label='Test')
plt.legend(prop=legend_properties)
plt.show()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)