admin管理员组文章数量:1594755
需要首先下载所需字体
黑体:simhei.ttf
宋体:SimSun.ttf
# 黑体
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
# 在此设置字体及大小
font = FontProperties(fname=r"/root/whq/font/simhei.ttf", size=14)
plt.figure()
plt.xlabel(u'x轴', FontProperties=font)
plt.ylabel(u'y轴', FontProperties=font)
plt.title(u'test——绘图', FontProperties=font)
import numpy as np
plt.plot(np.arange(1, 10), np.arange(1, 10))
宋体:
# 宋体
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
# 在此设置字体及大小
font = FontProperties(fname=r"/root/whq/font/SimSun.ttf", size=14)
plt.figure()
plt.xlabel(u'x轴', FontProperties=font)
plt.ylabel(u'y轴', FontProperties=font)
plt.title(u'test——绘图', FontProperties=font)
import numpy as np
plt.plot(np.arange(1, 10), np.arange(1, 10))
版权声明:本文标题:python绘图-中文字体 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1728201268a1149408.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论