iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Python(matplotlib)画图设置正斜体,及中文宋体、英文Timenews--用于论文画图,导出高清晰图像
  • 491
分享到

Python(matplotlib)画图设置正斜体,及中文宋体、英文Timenews--用于论文画图,导出高清晰图像

pythonmatplotlib开发语言 2023-09-01 17:09:26 491人浏览 泡泡鱼

Python 官方文档:入门教程 => 点击学习

摘要

一、设置图像x、y两轴及文本标签内容为中文宋体、英文Timenews,字体为10.5磅 在代码钱加入: config = { "font.family": 'serif', "font.size"

一、设置图像x、y两轴及文本标签内容为中文宋体、英文Timenews,字体为10.5磅

在代码钱加入:

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()

 一、设置图像x、y两轴及文本标签内容整体和斜体,和mathtype格式一样

mathit:斜体mathrm:正体

1.1 图中标签正斜体 

%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()

 1.2 x、y轴正斜体 

 这里先介绍怎么同时设置上下标,看代码照着做即可

%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://www.lsjlt.com/news/389166.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作