900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > matplotlib绘制图像设置中文宋体 英文新罗马 字体大小7.5 坐标轴刻度线内侧

matplotlib绘制图像设置中文宋体 英文新罗马 字体大小7.5 坐标轴刻度线内侧

时间:2023-01-02 02:29:53

相关推荐

matplotlib绘制图像设置中文宋体 英文新罗马 字体大小7.5 坐标轴刻度线内侧

import matplotlibimport numpy as npimport matplotlib.pyplot as pltfrom matplotlib import rcParamsmatplotlib.use("pgf")pgf_config = {"font.family": 'serif',"font.size": 7.5, #字体大小7.5"pgf.rcfonts": False,"text.usetex": True,"pgf.preamble": [r"\usepackage{unicode-math}",r"\setmainfont{Times New Roman}",r"\usepackage{xeCJK}",r"\setCJKmainfont{SimSun}",],}rcParams.update(pgf_config)plt.rcParams['xtick.direction'] = 'in'plt.rcParams['ytick.direction'] = 'in'#刻度内测,out外侧x = [1,2,3,4,5]y_y=[0.5,0.6,0.7,0.8,0.9]#原始图片#plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']#plt.rcParams['axes.unicode_minus'] = False#plt.figure(50)for i in range(len(y_y)):plt.text(x[i], y_y[i]+0.01, '%.3f' %(y_y[i]),ha='center')plt.plot(x, y_y,'rp--')#,label='Integrated algorithm'#plt.plot(x, y_1,'bp--',label='01')#plt.plot(x, y_2,'rp--',label='03')#plt.plot(x, y_200,'gp-',label='data=200')# set x limitsplt.xlim((0.8, 5.2))plt.ylim((0.8, 1))plt.xticks(x)#plt.xlabel('Number of data preprocessing',fontsize=13)#########x轴代表plt.xlabel('横纵')plt.ylabel('纵轴')############y轴代表plt.title('标题')###########title 14#plt.legend(loc='upper left',fontsize=13)#plt.show()plt.savefig('./集成2.png', dpi=800)

第一次运行需要安装插件,需要等待一会,安装完毕重新运行等待运行结束,查看保存图片的路径即可

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。