plot配色方案、Science期刊格式化输出图

一行代码绘制不同期刊格式图表

首先安装SciencePlots包

pip install SciencePlots

然后绘制图像

import numpy as np 
import matplotlib.pyplot as plt 

def model(x, p):
    return x ** (2 * p + 1) / (1 + x ** (2 * p))

x = np.linspace(0.75, 1.25, 201)

with plt.style.context(['science', 'no-latex']):
    fig, ax = plt.subplots()
    for p in [10, 15, 20, 30, 50, 100]:
        ax.plot(x, model(x, p), label=p)
    ax.legend(title='Order')
    ax.set(xlabel='Voltage (mV)')
    ax.set(ylabel='Current ($\mu$A)')
    ax.autoscale(tight=True)

在这里插入图片描述

with plt.style.context(['science', 'scatter', 'no-latex']):
    fig, ax = plt.subplots(figsize=(4,4))
    ax.plot([-2, 2], [-2, 2], 'k--')
    ax.fill_between([-2, 2], [-2.2, 1.8], [-1.8, 2.2], color='dodgerblue', alpha=0.2, lw=0)
    for i in range(7):
        x1 = np.random.normal(0, 0.5, 10)
        y1 = x1 + np.random.normal(0, 0.2, 10)
        ax.plot(x1, y1, label=r"$^\#${}".format(i+1))
    ax.legend(title='Sample', loc=2)
    ax.set_xlabel(r"$\log_{10}\left(\frac{L_\mathrm{IR}}{\mathrm{L}_\odot}\right)$")
    ax.set_ylabel(r"$\log_{10}\left(\frac{L_\mathrm{6.2}}{\mathrm{L}_\odot}\right)$")
    ax.set_xlim([-2, 2])
    ax.set_ylim([-2, 2])

在这里插入图片描述

不同的配色方案

with plt.style.context(['science', 'high-vis'])
with plt.style.context(['dark_background', 'science', 'high-vis'])
with plt.style.context(['science', 'notebook', 'no-latex'])
with plt.style.context(['science', 'bright'])
with plt.style.context(['science', 'vibrant'])
with plt.style.context(['science', 'muted'])
with plt.style.context(['science', 'retro'])
with plt.style.context(['science', 'grid'])
with plt.style.context(['science', 'high-contrast'])
with plt.style.context(['science', 'light'])
with plt.style.context(['science', 'scatter'])
with plt.style.context(['science', 'ieee'])
with plt.style.context(['science'])
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

听离

请作者吃个棒棒糖吧

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值