Python小工具(3)----- 学术论文快速作图(不同期刊格式图表)

Python数据分析:图表美观清晰,自带对比功能


本文转自Github 点此进入传送门

来自于哈佛天文研究所博士后自己制作的小工具,主要是在matplotlib上增加的一些小功能,支持调用不同期刊要求的格式进行作图

图示及翻译部分引用 量子位公众号推送文章

安装

pip就行(在Matplotlib基础上)

# for latest commit
pip install git+https://github.com/garrettj403/SciencePlots.git

# for lastest release
pip install SciencePlots

The pip installation will automatically move all of the *.mplstyle files into the appropriate directory. If you like, you can also do this manually. First, clone the repository and then copy all of the *.mplstyle files into your Matplotlib style directory. If you’re not sure where this is, in an interactive python console type:

# 手动安装 获得具体路径
import matplotlib
print(matplotlib.get_configdir())

编译器会返回Matplotlib的路径,你可能还需要手动建立一个stylelib文件夹。

使用

science.mplstyle 是这个补充包最基本的一种风格,基本满足一般科研论文的绘图要求,代码如下:

import matplotlib.pyplot as plt
 
plt.style.use('science')
plt.style.use(['science','ieee'])  

#the ieee style will override some of the parameters from the science style in order to configure the plot for IEEE papers (column width, fontsizes, etc.).
with plt.style.context(['science', 'ieee']):
    plt.figure()
    plt.plot(x, y)
    plt.show()

示例

science 风格
在这里插入图片描述
science+grid(网格)风格:
在这里插入图片描述
ieee风格:IEEE期刊对图表的尺寸、文字大小都有要求,同时还要求在黑白印刷时也能清晰呈现,下图是符合要求的science+ieee风格:
在这里插入图片描述
science+scatter(离散)风格:
在这里插入图片描述
Jupyter环境下的notebook风格:
在这里插入图片描述
补充包中的风格也可以和Matplotlib中的已有风格一起调用,例如dark_background + science + high-vis:

在这里插入图片描述
此外,扩展包还提供多种绘图==色彩搭配方案==
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
补充包默认使用Latex字体渲染,如果电脑中没有Latex,可以改用无Latex渲染模式:

plt.style.use(['science','no-latex'])

检查更新版本

pip install SciencePlots
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值