天体物理科研作图格式-要求-plot_example.py

本文介绍了天体物理科研作图的标准,特别是如何利用matplotlib库结合latex代码进行专业图表制作。重点讲解了astropy.io.fits模块在处理FITS文件中的应用,以及在matplotlib中使用latex代码设置坐标轴标签,如r""Lx,1035,erg,s^{-1}"",确保科学记数的正确呈现。" 7078652,1077200,RGB分量提取与显示,"['图像处理', '颜色空间', 'dst', 'merge']
摘要由CSDN通过智能技术生成

-latex code in matplotlib

天体物理科研作图要求
plot_example.py

import astropy.io.fits as pyfits
from pylab import *
import pylab
fig_width_pt = 255.76535  # Get this from LaTeX using \showthe\columnwidth
inches_per_pt = 1.0/72.27               # Convert pt to inches
golden_mean = 1.2*(sqrt(5)-1.0)/2.0         # Aesthetic ratio
fig_width = fig_width_pt*inches_per_pt  # width in inches
fig_height = fig_width*golden_mean       # height in inches
fig_size = [fig_width,fig_height]
params = {'axes.labelsize': 10,
          'font.size': 10,
          'legend.fontsize': 8,
          'xtick.labelsize': 8,
          'ytick.labelsize': 8,
          'text.usetex': True,
          # 'backend':'pdf',
          'figure.figsize': fig_size,
      "patch.linewidth": 0.5,
  "lines.linewidth":0.5,
"axes.linewidth":0.1}
pylab.rcParams.update(params)
pylab.rc('font',**{'family':'serif','serif':['Times']})

plot([1,2,3])	#Here should be changed.
xlabel('Energy, keV')	#Here should be changed.
ylabel(r'keV$^2$(Photons cm$^{-2}$s$^{-1}$keV$^{-1}$)')	#Here should be changed.

subplots_adjust(left=0.15,right=0.97,top=0.97,bottom=0.15)
savefig('example.pdf')

astropy.io.fits 提供对FITS文件的访问权限。
FITS (Flexible Image Transport System)是广泛用于天文界的存储图标的便携文件标准。

关于坐标,用matplotlib里的latex code,例如r" L x , 1 0 35 L_x, 10^{35} Lx,1035,erg,s − 1 ^{-1} 1"

r"$L_x, 10^{35}$\,erg\,s$^{-1}$
  • r"XX" syntax tells matplotlib to take the string literally and pass it to latex, might be needed if you use Tex for rendering.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值