Python 官方文档:入门教程 => 点击学习
一、设置图像x、y两轴及文本标签内容为中文宋体、英文Timenews,字体为10.5磅 在代码钱加入: config = { "font.family": 'serif', "font.size"
在代码钱加入:
config = { "font.family": 'serif', "font.size": 10.5, "mathtext.fontset": 'stix', "font.serif": ['SimSun'], }rcParams.update(config)
%config InlineBackend.figure_fORMat = 'retina'%matplotlib inlineimport numpy as npimport mathimport matplotlib.pyplot as pltfrom matplotlib import rcParamsconfig = { "font.family": 'serif', "font.size": 10.5, "mathtext.fontset": 'stix', "font.serif": ['SimSun'], }rcParams.update(config)x=[1,2,3]y=[1,2,3]plt.plot(x, y,label="时间随着距离的变换参数:y=0.5*x")plt.xlabel('时间参数/s')plt.ylabel('距离参数/v)')plt.legend() # 显示图例plt.show()
mathit:斜体mathrm:正体
%config InlineBackend.figure_format = 'retina'%matplotlib inlineimport numpy as npimport mathimport matplotlib.pyplot as pltfrom matplotlib import rcParamsconfig = { "font.family": 'serif', "font.size": 10.5, "mathtext.fontset": 'stix', "font.serif": ['SimSun'], }rcParams.update(config)x=[1,2,3]y=[1,2,3]#plt.plot(x, y,label="时间随着距离的变换参数:y=0.5*x")plt.plot(x, y, label=r'$\mathit{label}_{\mathrm{sub}}$')plt.xlabel('时间参数/s')plt.ylabel('距离参数/v)')plt.legend() # 显示图例plt.show()
这里先介绍怎么同时设置上下标,看代码照着做即可
%config InlineBackend.figure_format = 'retina'%matplotlib inlineimport numpy as npimport mathimport matplotlib.pyplot as pltfrom matplotlib import rcParamsconfig = { "font.family": 'serif', "font.size": 10.5, "mathtext.fontset": 'stix', "font.serif": ['SimSun'], }rcParams.update(config)x=[1,2,3]y=[1,2,3]plt.plot(x, y,label="时间随着距离的变换参数:y=0.5*x")plt.plot(x, y, label=r'$\mathit{label}_{\mathrm{sub}}$')plt.xlabel('Time (s)')plt.ylabel('Force ($\mathregular{F_{net}^{max}}$)')plt.legend() # 显示图例plt.show()
其次,上下标正斜体的设置,比如说把上图net设置为斜体:
%config InlineBackend.figure_format = 'retina'%matplotlib inlineimport numpy as npimport mathimport matplotlib.pyplot as pltfrom matplotlib import rcParamsconfig = { "font.family": 'serif', "font.size": 10.5, "mathtext.fontset": 'stix', "font.serif": ['SimSun'], }rcParams.update(config)x=[1,2,3]y=[1,2,3]plt.plot(x, y)plt.xlabel('Time (s)')plt.ylabel('Force ($\mathregular{F_{\mathit{net}}^{max}}$)')plt.show()
其次,上下标正斜体的设置,比如说把上图net改为整体、F改为斜体:
%config InlineBackend.figure_format = 'retina'%matplotlib inlineimport numpy as npimport mathimport matplotlib.pyplot as pltfrom matplotlib import rcParamsconfig = { "font.family": 'serif', "font.size": 10.5, "mathtext.fontset": 'stix', "font.serif": ['SimSun'], }rcParams.update(config)x=[1,2,3]y=[1,2,3]plt.plot(x, y)plt.xlabel('Time (s)')plt.ylabel('Force ($\mathregular{\mathit{F}_{net}^{max}}$)')plt.show()
来源地址:https://blog.csdn.net/qq_40214464/article/details/129908467
--结束END--
本文标题: Python(matplotlib)画图设置正斜体,及中文宋体、英文Timenews--用于论文画图,导出高清晰图像
本文链接: https://lsjlt.com/news/389166.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0