当前位置: 移动技术网 > IT编程>脚本编程>Python > 在matplotlib的图中设置中文标签的方法

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

2019年06月13日  | 移动技术网IT编程  | 我要评论

家居建材行业,郭德纲单口相声大全,劳拉失魂计

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

import matplotlib.pyplot as plt
from matplotlib.font_manager import fontproperties
font = fontproperties(fname=r"c:\windows\fonts\msyh.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 图中设置中文标签

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

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网