画布分块

数据文件:


image


程序:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_excel('compare.xlsx')

time = (data['start']+data['stop'])/2.0

fig, ax = plt.subplots(2,1,figsize=(9,9))
fig.subplots_adjust(hspace=0.0) # 上下两个图的距离,可不设置,默认是隔开一点。

ax[0].errorbar(time, data['aa_alpha'],yerr=data['aa_alphaerr'],color='g',alpha=0.5,fmt='.',label='A&A 588, A135')
ax[0].fill_between(time, data['aa_alpha']-data['aa_alphaerr'], data['aa_alpha']+data['aa_alphaerr'],color='g',alpha=0.5)
ax[0].errorbar(time, data['alpha'],yerr=data['alphaerr'],color='orange',alpha=0.5, fmt='.',label='my_results')
ax[0].fill_between(time, data['alpha']-data['alphaerr'], data['alpha']+data['alphaerr'],color='orange',alpha=0.5)
ax[0].set_xlabel('Time since trigger')
ax[0].set_ylabel(r'$\alpha$')
#ax[0].set_ylim(0,5000)
#ax[0].set_xlim(-0.024,0.174)
ax[0].grid()
ax[0].legend()
ax[0].set_title('Parameters of the PLBB Function for Resolved Spectroscopy of GRB 090902462')

ax[1].errorbar(time, data['aa_kT'],yerr=data['aa_kTerr'],color='g',alpha=0.5,fmt='.',label='A&A 588, A135')
ax[1].fill_between(time, data['aa_kT']-data['aa_kTerr'], data['aa_kT']+data['aa_kTerr'],color='g',alpha=0.5)
ax[1].errorbar(time, data['kT'],yerr=data['kTerr'],color='orange',alpha=0.5, fmt='.',label='my_results')
ax[1].fill_between(time, data['kT']-data['kTerr'], data['kT']+data['kTerr'],color='orange',alpha=0.5)
ax[1].set_xlabel('Time since trigger')
ax[1].set_ylabel(r'${kT}$')
#ax[1].set_ylim(0,5000)
#ax[1].set_xlim(-0.024,0.174)
ax[1].grid()
ax[1].legend()

fig.savefig('compare.jpg',dpi=800)

结果:
image

posted @ 2021-07-16 09:37  zhaopw5  阅读(39)  评论(0编辑  收藏  举报