栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

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

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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'])
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/879067.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号