当前位置: 首页 > article >正文

其他:python语言绘制案例

在这里插入图片描述

文章目录

    • 介绍
    • 导入python包
    • 图1
    • 图2

介绍

python语言的科研绘图合集,数据来源Hydrogen-diffusion-and-water-rock-reaction

导入python包

import pandas as pd
import glob
import proplot as pplt
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import patheffects
#import ternary
import scipy as scp
import matplotlib as mpl
import matplotlib.colors as mcolors
import matplotlib.cm as cm

pplt.rc.update({'xtick.major.size':6,
'xtick.minor.size':3.5,
'ytick.major.size':6,
'ytick.minor.size':3.5,
'tick.dir':'in',
'tick.labelsize':12,
'legend.columnspacing':0.1,
'legend.handletextpad':0.1,
'axes.labelsize':14,
'legend.fontsize':11,
#'cycle':'tab10'
})

图1

t=1e6*365*24*3600
c0=0.2e4
c1=4e4
h=200

d0=10
d1=-16
rsmow=0.0020052
c0D=(d0/1000+1)*c0*rsmow
c1D=(d1/1000+1)*c1*rsmow

fig,axs=pplt.subplots(ncols=2,nrows=1,figsize=(8,3),share=False)

#D0=np.array([10**2.24,10**1.11,np.exp(-7.3)/10000])[0]
#E=(np.array([374,334,118])*1e3)[0]
R=8.314
T=np.arange(200,601,1)
x=np.linspace(0,h,100)

x1,T1,j=np.meshgrid(x*1e-6,T+273.15,np.arange(0,300))
#D=D0*np.exp(-E/(R*T1))
DD=9e-9*np.exp(-49*4.184e3/R/T1) # diffusion coefficient of 2H
D=DD*np.sqrt(18/16) # diffusion coefficient of 1H

#######(a) dD varying with distance and temperature

sigma=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*D*t)
sumj=sigma.sum(axis=2)
c=c1+(c0-c1)*sumj

sigmaD=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*DD*t)
sumjD=sigmaD.sum(axis=2)
cD=c1D+(c0D-c1D)*sumjD

dD=(cD/c/rsmow-1)*1000

m=axs[0].contourf(x,T,dD,levels=np.linspace(-50,10,100),cmap='Oranges_r',extend='both')
axs[0].colorbar(m,loc='r',ticks=np.arange(-50,11,10),minorlocator=10,label=r'$\mathrm{\delta ^{18}O\ (‰)}$',width=0.15,pad=0.06,
                ticklabelsize=8,labelsize=10)
axs[0].text(0.97,0.9,'t=1 Ma',transform=axs[0].transAxes,fontsize=10,ha='right',c='k')
axs[0].format(xlim=(0,h),xlabel=r'$\mathrm{Distance\ ({\mu}m)}$',ylabel=r'$\mathrm{Temperature\ ({^o}C)}$')

##### (b)

t=10e6*365*24*3600

sigma=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*D*t)
sumj=sigma.sum(axis=2)
c=c1+(c0-c1)*sumj

sigmaD=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*DD*t)
sumjD=sigmaD.sum(axis=2)
cD=c1D+(c0D-c1D)*sumjD

dD=(cD/c/rsmow-1)*1000

m=axs[1].contourf(x,T,dD,levels=np.linspace(-50,10,100),cmap='Oranges_r',extend='both')
axs[1].colorbar(m,loc='r',ticks=np.arange(-50,11,10),minorlocator=10,label=r'$\mathrm{\delta ^{18}O\ (‰)}$',width=0.15,pad=0.06,
                ticklabelsize=8,labelsize=10)
axs[1].text(0.97,0.9,'t=10 Ma',transform=axs[1].transAxes,fontsize=10,ha='right',c='k')
axs[1].format(xlim=(0,h),xlabel=r'$\mathrm{Distance\ ({\mu}m)}$',ylabel=r'$\mathrm{Temperature\ ({^o}C)}$')

axs.format(abc='a',abcloc='ul',abc_kw={'fontsize':14})
#fig.savefig('d18O-diffusion.jpg',dpi=600)
   

在这里插入图片描述

图2

t=1e6*365*24*3600
c0=0.2e4
c1=4e4
h=200

d0=-50
d1=-60
rsmow=155.76e-6
c0D=(d0/1000+1)*c0*rsmow
c1D=(d1/1000+1)*c1*rsmow

fig,axs=pplt.subplots(ncols=2,nrows=1,figsize=(8,3),share=False)

#D0=np.array([10**2.24,10**1.11,np.exp(-7.3)/10000])[0]
#E=(np.array([374,334,118])*1e3)[0]
R=8.314
T=np.arange(0,201,1)
x=np.linspace(0,h,100)

x1,T1,j=np.meshgrid(x*1e-6,T+273.15,np.arange(0,300))
#D=D0*np.exp(-E/(R*T1))
DD=6.71e-13*np.exp(-80.5e3/R/T1) # diffusion coefficient of 2H
D=DD*np.sqrt(2) # diffusion coefficient of 1H

#######(a) dD varying with distance and temperature

sigma=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*D*t)
sumj=sigma.sum(axis=2)
c=c1+(c0-c1)*sumj

sigmaD=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*DD*t)
sumjD=sigmaD.sum(axis=2)
cD=c1D+(c0D-c1D)*sumjD

dD=(cD/c/rsmow-1)*1000

m=axs[0].contourf(x,T,dD,levels=np.linspace(-300,-50,100),cmap='Oranges_r',extend='both')
axs[0].colorbar(m,loc='r',ticks=np.arange(-300,-49,50),minorlocator=10,label=r'$\mathrm{\delta D\ (‰)}$',width=0.15,pad=0.06,
                ticklabelsize=8,labelsize=10)
axs[0].text(0.97,0.9,'t=1 Ma',transform=axs[0].transAxes,fontsize=10,ha='right',c='k')
axs[0].format(xlim=(0,h),xlabel=r'$\mathrm{Distance\ ({\mu}m)}$',ylabel=r'$\mathrm{Temperature\ ({^o}C)}$')

##### (b)

t=10e6*365*24*3600

sigma=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*D*t)
sumj=sigma.sum(axis=2)
c=c1+(c0-c1)*sumj

sigmaD=4/(2*j+1)/np.pi*np.sin(((2*j+1)*np.pi*x1)/h*1e6)*np.exp(-(((2*j+1)*np.pi)/h*1e6)**2*DD*t)
sumjD=sigmaD.sum(axis=2)
cD=c1D+(c0D-c1D)*sumjD

dD=(cD/c/rsmow-1)*1000

m=axs[1].contourf(x,T,dD,levels=np.linspace(-300,-50,100),cmap='Oranges_r',extend='both')
axs[1].colorbar(m,loc='r',ticks=np.arange(-300,-49,50),minorlocator=10,label=r'$\mathrm{\delta D\ (‰)}$',width=0.15,pad=0.06,
                ticklabelsize=8,labelsize=10)
axs[1].text(0.97,0.9,'t=10 Ma',transform=axs[1].transAxes,fontsize=10,ha='right',c='k')
axs[1].format(xlim=(0,h),xlabel=r'$\mathrm{Distance\ ({\mu}m)}$',ylabel=r'$\mathrm{Temperature\ ({^o}C)}$')

axs.format(abc='a',abcloc='ul',abc_kw={'fontsize':14})
#fig.savefig('dD-diffusion.jpg',dpi=600)

在这里插入图片描述


http://www.kler.cn/news/342540.html

相关文章:

  • 【图论】(一)图论理论基础与岛屿问题
  • 电视机/显示器参数1400nits 97% DCI-P3、ΔE<0.87和2400nits 110% DCI-P3、ΔE<0.6详解
  • 数据结构【C语言】[
  • C# + SQLiteExpert 进行(cipher)加密数据库开发+Costura.Fody 清爽发布
  • 番外篇 | CRAS-YOLO:基于卫星图像的多类别船舶检测和分类
  • 【分布式微服务云原生】Redis:如何实现高性能与高可用性的终极指南
  • 【华为HCIP实战课程十】OSPF网络DR和BDR实战讲解,网络工程师
  • 小北的技术博客:探索华为昇腾CANN训练营与AI技术创新——Ascend C算子开发能力认证考试(中级)
  • 设计模式之适配器模式(通俗易懂--代码辅助理解【Java版】)
  • windows启微服务端口被占用情况的排查与解决方法
  • 【uniapp】使用uniapp实现一个输入英文单词翻译组件
  • 【Linux】ComfyUI和SD WebUI之PYTHON环境共享,模型共享,LORA等公共资源共享
  • 实用Linux脚本
  • 【论文阅读】Cross Attention Network for Few-shot Classification
  • Golang | Leetcode Golang题解之第464题我能赢吗
  • c#中多态的实例应用说明
  • PHP智慧餐饮新风尚点餐系统
  • vscode 中显示 pnpm : 无法加载文件 C:\Users\AppData\Roaming\npm\pnpm.ps1,因为在此系统上禁止运行脚本
  • pytorch导入数据集
  • Python快速编程小案例——打印蚂蚁森林植树证书