网站开发兼职合同,江门网站建设费用,品牌宣传如何做,谷歌搜索引擎镜像文章目录 简介安装 LaTeXSciencePlots 绘图示例 简介
用户有时需要根据期刊的配图绘制要求进行诸如字体、刻度轴、轴脊、图例等图层属性的定制化修改#xff0c;耗时的同时也会容易导致用户忽略一些图层细节要求。
SciencePlots 作为一个专门用于科研论文绘图的第三方拓展工… 文章目录 简介安装 LaTeXSciencePlots 绘图示例 简介
用户有时需要根据期刊的配图绘制要求进行诸如字体、刻度轴、轴脊、图例等图层属性的定制化修改耗时的同时也会容易导致用户忽略一些图层细节要求。
SciencePlots 作为一个专门用于科研论文绘图的第三方拓展工具包提供了主流英文科技期刊如 Nature、Science 和 IEEE 等的 Matplotlib 图样式Matplotlib Styles。
SciencePlots 的安装代码如下
pip install SciencePlots安装 LaTeX
为了更好地显示学术论文插图和方便后续印刷插图中的字体样式一般要求为 LaTeX 编写样式SciencePlots 可以简单地实现该要求。SciencePlots 库实现 LaTeX 编写样式需要使用者在计算机上安装 LaTeX。 其余类型操作系统安装步骤参考 SciencePlots 官方教程即可。 安装 MikTex 和 Ghostscript ScienePlots 库官方建议用户使用 MikTex 软件安装 LaTeX用户直接从 MikTex 官网下载其最新版本并安装即可。Ghostscript 是一套建基于 Adobe、PostScript 及可移植文档格式PDF的页面描述语言等而编译成的免费软件用户可从其官网下载最新版本并安装。将软件的安装路径添加到系统环境变量中 在安装了上述两款软件后用户还需要将它们的安装路径添加到系统环境变量中具体为“\...\miktex\bin\x64”和“\...\gs__( 版本号)\bin”。添加完系统环境变量后重启相关配置即可生效。
SciencePlots 绘图示例 如果读者投稿的期刊有特殊字体要求那么读者可设置不使用 LaTeX 绘图plt.style.use([science, no-latex])。 下图为 SciencePlots 中多种绘图风格示例 a为 Matplotlib 的默认颜色主题和绘图风格
import pandas as pd
import numpy as np
import matplotlib.pyplot as pltdata pd.read_excel(r\分组误差线图构建.xlsx)#(a)Matplotlib的默认颜色主题和绘图风格
selsect [A,B,C,D]
colors [#2FBE8F,#459DFF,#FF5B9B,#FFCC37]
fig,ax plt.subplots(figsize(4,3.5),dpi100,facecolorw)for index,color in zip(selsect,colors):data_selcet data.loc[data[type]index,:]ax.errorbar(xdata_selcet[time],ydata_selcet[mean],yerrdata_selcet[sd],linewidth1,markero,ms10,mew1,meck,capsize5,labelindex)ax.legend()ax.set(xlabelTime, ylabelValues,xlim(-2,40),ylim(-8,30))plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 ScienecePlots_matplotlib.png, bbox_inchestight,dpi600)
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 ScienecePlots_matplotlib.pdf, bbox_inchestight)
plt.show()b为 Science 系列期刊风格绘制结果
#(b)Science系列期刊风格绘制结果selsect [A,B,C,D]
colors [#2FBE8F,#459DFF,#FF5B9B,#FFCC37]
plt.style.use(science)
fig,ax plt.subplots(figsize(4,3.5),dpi100,facecolorw)
for index,color in zip(selsect,colors):data_selcet data.loc[data[type]index,:]ax.errorbar(xdata_selcet[time],ydata_selcet[mean],yerrdata_selcet[sd],linewidth1,markero,ms10,mew1,meck,capsize5,labelindex)ax.legend()ax.set(xlabelTime, ylabelValues,xlim(-2,40),ylim(-8,30))
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_science.png, bbox_inchestight,dpi600)
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_science.pdf, bbox_inchestight)
plt.show()c为 IEEE 期刊风格绘制结果
#(c)IEEE期刊风格绘制结果
selsect [A,B,C,D]
colors [#2FBE8F,#459DFF,#FF5B9B,#FFCC37]
plt.style.use([science,ieee])
fig,ax plt.subplots(figsize(4,3.5),dpi100,facecolorw)
for index,color in zip(selsect,colors):data_selcet data.loc[data[type]index,:]ax.errorbar(xdata_selcet[time],ydata_selcet[mean],yerrdata_selcet[sd],linewidth1,markero,ms10,mew1,meck,capsize5,labelindex)ax.legend()ax.set(xlabelTime, ylabelValues,xlim(-2,40),ylim(-8,30))
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_ieee.png, bbox_inchestight,dpi600)
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_ieee.pdf, bbox_inchestight)
plt.show()d为 Nature 期刊风格绘制结果
#(d)Nature期刊风格绘制结果
colors [#2FBE8F,#459DFF,#FF5B9B,#FFCC37]
selsect [A,B,C,D]
plt.style.use([science,nature])
fig,ax plt.subplots(figsize(4,3.5),dpi100,facecolorw)
for index,color in zip(selsect,colors):data_selcet data.loc[data[type]index,:]ax.errorbar(xdata_selcet[time],ydata_selcet[mean],yerrdata_selcet[sd],linewidth1,markero,ms10,mew1,meck,capsize5,labelindex)ax.legend()ax.set(xlabelTime, ylabelValues,xlim(-2,40),ylim(-8,30))plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_nature.png, bbox_inchestight,dpi600)
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_nature.pdf, bbox_inchestight)
plt.show()e为使用了 vibrant 颜色主题的 Science 期刊绘图风格
#(e)使用了vibrant 颜色主题的Science期刊绘图风格
selsect [A,B,C,D]
plt.style.use([science,vibrant])
fig,ax plt.subplots(figsize(4,3.5),dpi100,facecolorw)
for index,color in zip(selsect,colors):data_selcet data.loc[data[type]index,:]ax.errorbar(xdata_selcet[time],ydata_selcet[mean],yerrdata_selcet[sd],linewidth1,markero,ms10,mew1,meck,capsize5,labelindex)ax.legend()ax.set(xlabelTime, ylabelValues,xlim(-2,40),ylim(-8,30))plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_vibrant.png, bbox_inchestight,dpi600)
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_vibrant.pdf, bbox_inchestight)
plt.show()f为使用了 bright 颜色主题的 Science 期刊绘图风格
#(f)使用了bright颜色主题的Science期刊绘图风格
selsect [A,B,C,D]
plt.style.use([science,bright])
fig,ax plt.subplots(figsize(4,3.5),dpi100,facecolorw)
for index,color in zip(selsect,colors):data_selcet data.loc[data[type]index,:]ax.errorbar(xdata_selcet[time],ydata_selcet[mean],yerrdata_selcet[sd],linewidth1,markero,ms10,mew1,meck,capsize5,labelindex)ax.legend()ax.set(xlabelTime, ylabelValues,xlim(-2,40),ylim(-8,30))plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_bright.png, bbox_inchestight,dpi600)
plt.savefig(\第2章 绘制工具及其重要特征\图2-3-8 SciencePlots_bright.pdf, bbox_inchestight)
plt.show()更多绘图风格参考 SciencePlots 官网。 提示SciencePlots 库不但提供了主流英文科技期刊的绘图风格模板而且能够实现不同绘图风格的混合使用。此外在使用该库的绘图风格时读者可通过plt.style.use(science) 设置全局绘图风格也可通过以下语句来临时使用绘图风格。
with plt.style.context(science ):plt.figure()plt.plot(x,y)plt.show()建议使用全局设置因为在使用临时绘图风格特别是使用了 LaTeX 字符时将导致绘制图例、轴标签等图层属性时无法使用 LaTeX 字符风格造成绘图结果整体不协调问题。引入 SciencePlots 绘图主题样式的方式可能会随着版本的更新有所不同读者应查看 SciencePlots 官网使用其最新的引入方式。 参考书籍宁海涛.科研论文配图绘制指南——基于Python[M].北京人民邮电出版社202342-44.