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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

YangJianShuai   2021-03-30 我要评论

其实就是通过 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的图中设置中文标签的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们