在matplotlib的图中设置中文标签的方法

在matplotlib的图中设置中文标签的方法,第1张

在matplotlib的图中设置中文标签的方法

其实就是通过 FontProperties来设置的,请参考以下代码:

import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:windowsfontsmsyh.ttc", size=15)

plt.title("散点图练习", fontproperties=font)
plt.scatter([1, 2, 3, 4, 5, 6], [2, 3, 4, 6, 9, 12])
plt.xlabel('横坐标', fontproperties=font)
plt.ylabel('纵坐标', fontproperties=font)
plt.show()

结果如下:

以上这篇在matplotlib的图中设置中文标签的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持考高分网。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/zaji/3280680.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-10-05
下一篇 2022-10-05

发表评论

登录后才能评论

评论列表(0条)

保存