本文讲述了Python画图包的高阶用法,主要功能是实现多阵列子图组合,以及美化~


Code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
from pylab import *
from scipy.stats import norm
import matplotlib.gridspec as gridspec
from scipy.stats import ks_2samp
from qqplotfunc import qqplot

plt.switch_backend('agg')
#Read original excel
original=pd.read_excel('common_lgrb_list_minus2.xlsx')
z=original['z']
fermi_t90=original['Fermi_t90']
swift_t90=original['Swift_t90']
fermi_ep=original['flnc_epeak']
fermi_pfl_ep=original['pflx_epeak']

original_swift_ind=pd.read_excel('swift_ind_minus3.xlsx')
swift_z_ind=original_swift_ind['z']
swift_t90_ind=original_swift_ind['T90']

original_fermi_ind=pd.read_excel('fermi_ind.xlsx')
fermi_z_ind=original_fermi_ind['z']
fermi_t90_ind=original_fermi_ind['t90']
fermi_ep_ind=original_fermi_ind['flnc_epeak']
fermi_pfl_ep_ind=original_fermi_ind['pflx_epeak']

swift_all=pd.read_excel('swift_t90.xlsx')
fermi_all=pd.read_excel('fermi_t90.xlsx')
swift_all_t90=swift_all['T90']
fermi_all_t90=fermi_all['t90']

#Read repo 
fermi_eiso_repo=pd.read_csv('calresult_band/fermi_\
	eiso_repo.txt')
fermi_l_repo=pd.read_csv('calresult_band/fermi_l_\
	repo.txt')
fermi_lp_repo=pd.read_csv('calresult_band/fermi_lp\
	_repo.txt')

fermi_eiso_repo_ind=pd.read_csv('calresult_band/\
	fermi_eiso_ind_repo.txt')
fermi_l_repo_ind=pd.read_csv('calresult_band/fermi\
	_l_ind_repo.txt')
fermi_lp_repo_ind=pd.read_csv('calresult_band/fermi\
	_lp_ind_repo.txt')


swift_eiso_repo_fspec=pd.read_csv('calresult_band/swift\
	_eiso_fspec_repo.txt')
swift_l_repo_fspec=pd.read_csv('calresult_band/swift_l\
	_fspec_repo.txt')
swift_lp_repo_fspec=pd.read_csv('calresult_band/swift_\
	lp_fspec_repo.txt')


swift_eiso_repo_pl=pd.read_csv('calresult_band/swift_\
	eiso_pl_repo.txt')
swift_l_repo_pl=pd.read_csv('calresult_band/swift_l_pl\
	_repo.txt')
swift_lp_repo_pl=pd.read_csv('calresult_band/swift_lp_\
	pl_repo.txt')

swift_eiso_repo_ind_pl=pd.read_csv('calresult_band/swift\
	_eiso_ind_pl_repo.txt')
swift_l_repo_ind_pl=pd.read_csv('calresult_band/swift_\
	l_ind_pl_repo.txt')
swift_lp_repo_ind_pl=pd.read_csv('calresult_band/swift_\
	lp_ind_pl_repo.txt')


swift_eiso_repo_emp=pd.read_csv('calresult_band/swift_eiso\
	_emp_repo.txt')
swift_l_repo_emp=pd.read_csv('calresult_band/swift_l_emp_\
	repo.txt')
swift_lp_repo_emp=pd.read_csv('calresult_band/swift_lp_emp\
	_repo.txt')

swift_eiso_repo_ind_emp=pd.read_csv('calresult_band/swift_\
	eiso_ind_emp_repo.txt')
swift_l_repo_ind_emp=pd.read_csv('calresult_band/swift_l_ind\
	_emp_repo.txt')
swift_lp_repo_ind_emp=pd.read_csv('calresult_band/swift_lp_\
	ind_emp_repo.txt')



#<<<<<<<<<<<<<<<<<<<<<<<<<<<< plot >>>>>>>>>>>>>>>>>>>>>>>>>>>>#
matplotlib.rcParams['xtick.direction']='in'
matplotlib.rcParams['ytick.direction']='in'

plt.figure(figsize=(24,36))
gs = gridspec.GridSpec(10,6, width_ratios=[3,3,1,1,2,2],\
	height_ratios=[1,1,2,2,2,2,2,2,2,2])

############################
############################    
############################	Eiso
############################
############################
num_bin_f=11
n_f,bins_f,patches = plt.hist(np.array(np.log10(\
	fermi_z_ind+1))\
	,num_bin_f,density=1)
n_f=np.append(0.0,n_f)
n_f=np.append(n_f,0.0)
bins_f=np.append(bins_f,bins_f[num_bin_f-1]+bins_f[2]-\
	bins_f[1])
num_bin_s=12
n_s,bins_s,patches = plt.hist(np.array(np.log10(\
	swift_z_ind+1)),\
	num_bin_s,density=1)
n_s=np.append(0.0,n_s)
n_s=np.append(n_s,0.0)
bins_s=np.append(bins_s,bins_s[num_bin_s-1]+bins_s[2]-\
	bins_s[1])

plt.subplot(gs[:2,:2])
plt.step(10**bins_f,n_f,linewidth=1.4,linestyle='-',\
	c='blue',\
	alpha=0.5)
x_f=y_f=[]
for i in range(len(bins_f)-1):
	x_f_tmp=np.arange(bins_f[i],bins_f[i+1],(bins_f[\
		int(num_bin_f/2)\
		+1]-bins_f[int(num_bin_f/2)])/50)
	for j in range(len(x_f_tmp)):
		y_f=np.append(y_f,n_f[i+1])
	x_f=np.append(x_f,x_f_tmp)
x_f=np.append(x_f[0],x_f)
x_f=np.append(x_f,x_f[len(x_f)-1])
y_f=np.append(0.0,y_f)
y_f=np.append(y_f,0.0)
plt.fill(10**(x_f),y_f,c='blue',alpha=0.2,label='Fermi')

plt.step(10**bins_s,n_s,linewidth=1.4,linestyle='-',c='red',\
	alpha=0.5)
x_s=y_s=[]
for i in range(len(bins_s)-1):
	x_s_tmp=np.arange(bins_s[i],bins_s[i+1],\
		(bins_s[6]-bins_s[5])\
		/50)
	for j in range(len(x_s_tmp)):
		y_s=np.append(y_s,n_s[i+1])
	x_s=np.append(x_s,x_s_tmp)
x_s=np.append(x_s[0],x_s)
x_s=np.append(x_s,x_s[len(x_s)-1])
y_s=np.append(0.0,y_s)
y_s=np.append(y_s,0.0)
plt.fill(10**(x_s),y_s,c='red',alpha=0.2,label='Swift')

plt.xscale('log')
plt.xticks([])
plt.yticks([])
plt.axis('off')
plt.legend(loc='center right',fontsize='26')
plt.xlim((1,10**(1.1)))
plt.ylim(bottom=0.)


plt.subplot(gs[2:4,:2])
plt.tick_params(which='major',length=5)
plt.tick_params(top=True,bottom=True,left=True,\
	right=True)
swift=plt.scatter(swift_z_ind+1,swift_eiso_repo_ind_pl\
	,s=10,\
	alpha=0.45,marker='D',c='r')
fermi=plt.scatter(fermi_z_ind+1,fermi_eiso_repo_ind,\
	s=20,\
	alpha=0.7,marker='o',c='blue')
plt.text(10**0.86,10**51.2,'$P_{K-S}^{2d}=0.151$',\
	fontsize='24'\
	,ha='left',wrap=True)
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((1e50,1e56))
# plt.xlabel('$log\;(z+1)$',fontsize='20')
# # plt.ylabel('$log\;(E_{iso}\;/ \;erg)$',fontsize='26')
plt.xticks([10**1],[],fontsize='18')
plt.yticks([10**51,10**52,10**53,10**54,10**55],\
	[51,52,53,54,55]\
	,fontsize='18')
plt.legend((fermi,swift),('Fermi','Swift-pl'),\
	loc='lower right'\
	,fontsize='24')
plt.twinx()
plt.twiny()
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((1e50,1e56))
plt.xticks([10**1,10**1],[])
plt.yticks([10**50,10**51,10**52,10**53,10**54,\
	10**55,10**56],[])


num_bin_f=9
mu_f=np.mean(np.log10(fermi_eiso_repo_ind))
sigma_f=np.std(np.log10(fermi_eiso_repo_ind))
arr_f=np.linspace(49,56,100)
yline_f=norm.pdf(arr_f,mu_f,sigma_f)
n_f,bins_f,patches = plt.hist(np.array(np.log10\
	(fermi_eiso_repo_ind)),num_bin_f,density=1)
n_f=np.append(0.0,n_f)
n_f=np.append(n_f,0.0)
bins_f=np.append(bins_f[0]+bins_f[2]-bins_f[1],bins_f)

num_bin_s=16
mu_s=np.mean(np.log10(swift_eiso_repo_ind_pl))
sigma_s=np.std(np.log10(swift_eiso_repo_ind_pl))
arr_s=np.linspace(49,56,100)
yline_s=norm.pdf(arr_s,mu_s,sigma_s)
n_s,bins_s,patches = plt.hist(np.array(np.log10\
	(swift_eiso_repo_ind_pl)),num_bin_s,density=1)
n_s=np.append(0.0,n_s)
n_s=np.append(n_s,0.0)
bins_s=np.append(bins_s[0]+bins_s[2]-bins_s[1],bins_s)

plt.subplot(gs[2:4,2:4])
plt.step(n_f,10**bins_f,linewidth=1.4,linestyle='-',\
	c='blue',alpha=0.5)
x_f=y_f=[]
for i in range(len(bins_f)-1):
	x_f_tmp=np.arange(bins_f[i],bins_f[i+1],(bins_f\
		[int(num_bin_f/2)+1]-bins_f[int(num_bin_f/2)])/50)
	for j in range(len(x_f_tmp)):
		y_f=np.append(y_f,n_f[i])
	x_f=np.append(x_f,x_f_tmp)
x_f=np.append(x_f[0],x_f)
x_f=np.append(x_f,x_f[len(x_f)-1])
y_f=np.append(0.0,y_f)
y_f=np.append(y_f,0.0)
plt.fill(y_f,10**(x_f),c='blue',alpha=0.2)
plt.plot(yline_f,10**arr_f,linewidth=1.4,linestyle='\
	dashed',c='blue')

plt.step(n_s,10**bins_s,linewidth=1.4,linestyle='-',\
	c='red',alpha=0.5)
x_s=y_s=[]
for i in range(len(bins_s)-1):
	x_s_tmp=np.arange(bins_s[i],bins_s[i+1],(bins_s[6]-\
		bins_s[5])/50)
	for j in range(len(x_s_tmp)):
		y_s=np.append(y_s,n_s[i])
	x_s=np.append(x_s,x_s_tmp)
x_s=np.append(x_s[0],x_s)
x_s=np.append(x_s,x_s[len(x_s)-1])
y_s=np.append(0.0,y_s)
y_s=np.append(y_s,0.0)
plt.fill(y_s,10**(x_s),c='red',alpha=0.2)
plt.plot(yline_s,10**arr_s,linewidth=1.9,linestyle=\
	'dashed',c='red')

plt.yscale('log')
plt.xticks([])
plt.yticks([])
plt.axis('off')
plt.xlim(0,0.65)
plt.ylim((1e50,1e56))


ax=plt.subplot(gs[4:6,:2])
plt.tick_params(which='major',length=5)
plt.tick_params(top=True,bottom=True,left=True,\
	right=True)
plt.scatter(swift_z_ind+1,swift_eiso_repo_ind_emp,s=10,\
	alpha=0.45,marker='D',c='r')
plt.scatter(fermi_z_ind+1,fermi_eiso_repo_ind,s=20,\
	alpha=0.7,marker='o',c='blue')
plt.text(10**0.83,10**51.2,'$P_{K-S}^{2d}=1.80$E-03',\
	fontsize='24',ha='left',wrap=True)
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((1e50,1e56))
# plt.xlabel('$log\;(z+1)$',fontsize='20')
label=ax.set_ylabel('$log\;(E_{iso}\;/ \;erg)$',\
	fontsize='30')
ax.yaxis.set_label_coords(-0.03,1.0)
plt.xticks([10**1],[],fontsize='18')
plt.yticks([10**51,10**52,10**53,10**54,10**55],\
	[51,52,53,54,55],fontsize='18')
plt.legend((fermi,swift),('Fermi','Swift-emp'),\
	loc='lower right',fontsize='24')
plt.twinx()
plt.twiny()
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((1e50,1e56))
plt.xticks([10**1,10**1],[])
plt.yticks([10**50,10**51,10**52,10**53,10**54,\
	10**55,10**56],[])


num_bin_f=9
mu_f=np.mean(np.log10(fermi_eiso_repo_ind))
sigma_f=np.std(np.log10(fermi_eiso_repo_ind))
arr_f=np.linspace(49,56,100)
yline_f=norm.pdf(arr_f,mu_f,sigma_f)
n_f,bins_f,patches = plt.hist(np.array(np.log10\
	(fermi_eiso_repo_ind)),num_bin_f,density=1)
n_f=np.append(0.0,n_f)
n_f=np.append(n_f,0.0)
bins_f=np.append(bins_f[0]+bins_f[2]-bins_f[1],bins_f)
num_bin_s=20
mu_s=np.mean(np.log10(swift_eiso_repo_ind_emp))
sigma_s=np.std(np.log10(swift_eiso_repo_ind_emp))
arr_s=np.linspace(49,56,100)
yline_s=norm.pdf(arr_s,mu_s,sigma_s)
n_s,bins_s,patches = plt.hist(np.array(np.log10\
	(swift_eiso_repo_ind_emp)),num_bin_s,density=1)
n_s=np.append(0.0,n_s)
n_s=np.append(n_s,0.0)
bins_s=np.append(bins_s[0]+bins_s[2]-bins_s[1],bins_s)


plt.subplot(gs[4:6,2:4])
plt.step(n_f,10**bins_f,linewidth=1.4,linestyle='-',\
	c='blue',alpha=0.5)
x_f=y_f=[]
for i in range(len(bins_f)-1):
	x_f_tmp=np.arange(bins_f[i],bins_f[i+1],(bins_f\
		[int(num_bin_f/2)+1]-bins_f[int(num_bin_f/\
			2)])/50)
	for j in range(len(x_f_tmp)):
		y_f=np.append(y_f,n_f[i])
	x_f=np.append(x_f,x_f_tmp)
x_f=np.append(x_f[0],x_f)
x_f=np.append(x_f,x_f[len(x_f)-1])
y_f=np.append(0.0,y_f)
y_f=np.append(y_f,0.0)
plt.fill(y_f,10**(x_f),c='blue',alpha=0.2)
plt.plot(yline_f,10**arr_f,linewidth=1.4,linestyle=\
	'dashed',c='blue')

plt.step(n_s,10**bins_s,linewidth=1.4,linestyle='-',\
	c='red',alpha=0.5)
x_s=y_s=[]
for i in range(len(bins_s)-1):
	x_s_tmp=np.arange(bins_s[i],bins_s[i+1],\
		(bins_s[6]-bins_s[5])/50)
	for j in range(len(x_s_tmp)):
		y_s=np.append(y_s,n_s[i])
	x_s=np.append(x_s,x_s_tmp)
x_s=np.append(x_s[0],x_s)
x_s=np.append(x_s,x_s[len(x_s)-1])
y_s=np.append(0.0,y_s)
y_s=np.append(y_s,0.0)
plt.fill(y_s,10**(x_s),c='red',alpha=0.2)
plt.plot(yline_s,10**arr_s,linewidth=1.9,linestyle=\
	'dashed',c='red')
plt.yscale('log')
plt.xticks([])
plt.yticks([])

plt.axis('off')
plt.xlim(0,0.65)
plt.ylim((1e50,1e56))


plt.subplot(gs[3:5,4:6])
xx=np.linspace(47,56,50)
yy=xx
plt.plot(10**xx,10**yy,c='black',linewidth=0.8,\
	linestyle='dashed')
qqplot(swift_eiso_repo_ind_pl,fermi_eiso_repo_ind,\
	s=30,alpha=0.8,marker='o',c='orange',edgecolors=\
	'k',label='Swift-tot-pl')
qqplot(swift_eiso_repo_ind_emp,fermi_eiso_repo_ind,\
	s=30,alpha=0.7,marker='D',c='green',edgecolors='k',\
	label='Swift-tot-emp')
plt.xscale('log')
plt.yscale('log')
plt.xlim((1e50,1e56))
plt.ylim((1e50,1e56))
plt.xlabel('$Swift\;Quantiles\;\,log\;(E_{iso}\;/ \;erg\
	)$',fontsize='30')
plt.ylabel('$Fermi\;Quantiles\;\,log\;(E_{iso}\;/ \;erg\
	)$',fontsize='30')
plt.xticks([10**51,10**52,10**53,10**54,10**55,10**56]\
	,[51,52,53,54,55,56],fontsize='18')
plt.yticks([10**51,10**52,10**53,10**54,10**55,10**56]\
	,[51,52,53,54,55,56],fontsize='18')
plt.legend(loc='lower right',fontsize='24')
plt.twinx()
plt.twiny()
plt.xscale('log')
plt.yscale('log')
plt.xlim((1e50,1e56))
plt.ylim((1e50,1e56))
plt.xticks([10**51,10**52,10**53,10**54,10**55,\
	10**56],[])
plt.yticks([10**51,10**52,10**53,10**54,10**55,\
	10**56],[])


############################
############################    
############################	Luminosity
############################
############################
plt.subplot(gs[6:8,:2])
plt.tick_params(which='major',length=5)
plt.tick_params(top=True,bottom=True,left=True,\
	right=True)
swift=plt.scatter(swift_z_ind+1,swift_lp_repo_ind_pl\
	,s=10,alpha=0.45,marker='D',c='r')
fermi=plt.scatter(fermi_z_ind+1,fermi_lp_repo_ind,\
	s=20,alpha=0.7,marker='o',c='blue')
plt.text(10**0.86,10**48.4,'$P_{K-S}^{2d}=0.149$',\
	fontsize='24',ha='left',wrap=True)
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((10**46.8,1e55))
plt.xticks([10**1],[],fontsize='18')
plt.yticks([10**47,10**48,10**49,10**50,10**51,10**52,\
	10**53,10**54],[47,48,49,50,51,52,53,54],fontsize='18')
plt.legend((fermi,swift),('Fermi','Swift-pl'),\
	loc='lower right',fontsize='24')
plt.twinx()
plt.twiny()
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((10**46.8,1e55))
plt.xticks([10**1,10**1],[])
plt.yticks([10**47,10**48,10**49,10**50,10**51,10**52\
	,10**53,10**54,10**55],[])


num_bin_f=8
mu_f=np.mean(np.log10(fermi_lp_repo_ind))
sigma_f=np.std(np.log10(fermi_lp_repo_ind))
arr_f=np.linspace(48.5,56,100)
yline_f=norm.pdf(arr_f,mu_f,sigma_f)
n_f,bins_f,patches = plt.hist(np.array(np.log10(\
	fermi_lp_repo_ind)),num_bin_f,density=1)
n_f=np.append(0.0,n_f)
n_f=np.append(n_f,0.0)
bins_f=np.append(bins_f[0]+bins_f[2]-bins_f[1],bins_f)
num_bin_s=20
mu_s=np.mean(np.log10(swift_lp_repo_ind_pl))
sigma_s=np.std(np.log10(swift_lp_repo_ind_pl))
arr_s=np.linspace(48.5,56,100)
yline_s=norm.pdf(arr_s,mu_s,sigma_s)
n_s,bins_s,patches = plt.hist(np.array(np.log10(\
	swift_lp_repo_ind_pl)),num_bin_s,density=1)
n_s=np.append(0.0,n_s)
n_s=np.append(n_s,0.0)
bins_s=np.append(bins_s[0]+bins_s[2]-bins_s[1],bins_s)

plt.subplot(gs[6:8,2:4])
plt.step(n_f,10**bins_f,linewidth=1.4,linestyle='-',\
	c='blue',alpha=0.5)
x_f=y_f=[]
for i in range(len(bins_f)-1):
	x_f_tmp=np.arange(bins_f[i],bins_f[i+1],(\
		bins_f[int(num_bin_f/2)+1]-bins_f[int(\
			num_bin_f/2)])/50)
	for j in range(len(x_f_tmp)):
		y_f=np.append(y_f,n_f[i])
	x_f=np.append(x_f,x_f_tmp)
x_f=np.append(x_f[0],x_f)
x_f=np.append(x_f,x_f[len(x_f)-1])
y_f=np.append(0.0,y_f)
y_f=np.append(y_f,0.0)
plt.fill(y_f,10**(x_f),c='blue',alpha=0.2)
plt.plot(yline_f,10**arr_f,linewidth=1.4,linestyle=\
	'dashed',c='blue')

plt.step(n_s,10**bins_s,linewidth=1.4,linestyle='-',\
	c='red',alpha=0.5)
x_s=y_s=[]
for i in range(len(bins_s)-1):
	x_s_tmp=np.arange(bins_s[i],bins_s[i+1],(\
		bins_s[6]-bins_s[5])/50)
	for j in range(len(x_s_tmp)):
		y_s=np.append(y_s,n_s[i])
	x_s=np.append(x_s,x_s_tmp)
x_s=np.append(x_s[0],x_s)
x_s=np.append(x_s,x_s[len(x_s)-1])
y_s=np.append(0.0,y_s)
y_s=np.append(y_s,0.0)
plt.fill(y_s,10**(x_s),c='red',alpha=0.2)
plt.plot(yline_s,10**arr_s,linewidth=1.9,linestyle=\
	'dashed',c='red')
plt.yscale('log')
plt.xticks([])
plt.yticks([])

plt.axis('off')
plt.xlim(0,0.65)
plt.ylim((10**46.8,1e55))



ax=plt.subplot(gs[8:10,:2])
plt.tick_params(which='major',length=5)
plt.tick_params(top=True,bottom=True,left=True,\
	right=True)
swift=plt.scatter(swift_z_ind+1,swift_lp_repo_ind_emp\
	,s=10,alpha=0.45,marker='D',c='r')
fermi=plt.scatter(fermi_z_ind+1,fermi_lp_repo_ind,s=20\
	,alpha=0.7,marker='o',c='blue')
plt.text(10**0.83,10**48.2,'$P_{K-S}^{2d}=3.29$E-03'\
	,fontsize='24',ha='left',wrap=True)
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((10**46.5,1e55))
plt.xlabel('$log\;(z+1)$',fontsize='30')
label=ax.set_ylabel('$log\;(L_{peak}\;/\;erg\,\,s^{-1})$'\
	,fontsize='30')
ax.yaxis.set_label_coords(-0.03,1.0)
plt.xticks([10**1],[1],fontsize='18')
plt.yticks([10**47,10**48,10**49,10**50,10**51,10**52,\
	10**53,10**54],[47,48,49,50,51,52,53,54],fontsize='18')
plt.legend((fermi,swift),('Fermi','Swift-emp'),\
	loc='lower right',fontsize='24')
plt.twinx()
plt.twiny()
plt.xscale('log')
plt.yscale('log')
plt.xlim((1,10**(1.1)))
plt.ylim((10**46.5,1e55))
plt.xticks([10**1,10**1],[])
plt.yticks([10**47,10**48,10**49,10**50,10**51,10**52,\
	10**53,10**54,10**55],[])


num_bin_f=8
mu_f=np.mean(np.log10(fermi_lp_repo_ind))
sigma_f=np.std(np.log10(fermi_lp_repo_ind))
arr_f=np.linspace(48.5,56,100)
yline_f=norm.pdf(arr_f,mu_f,sigma_f)
n_f,bins_f,patches = plt.hist(np.array(np.log10(\
	fermi_lp_repo_ind)),num_bin_f,density=1)
n_f=np.append(0.0,n_f)
n_f=np.append(n_f,0.0)
bins_f=np.append(bins_f[0]+bins_f[2]-bins_f[1],bins_f)
num_bin_s=20
mu_s=np.mean(np.log10(swift_lp_repo_ind_emp))
sigma_s=np.std(np.log10(swift_lp_repo_ind_emp))
arr_s=np.linspace(48.5,56,100)
yline_s=norm.pdf(arr_s,mu_s,sigma_s)
n_s,bins_s,patches = plt.hist(np.array(np.log10(\
	swift_lp_repo_ind_emp)),num_bin_s,density=1)
n_s=np.append(0.0,n_s)
n_s=np.append(n_s,0.0)
bins_s=np.append(bins_s[0]+bins_s[2]-bins_s[1],bins_s)

plt.subplot(gs[8:10,2:4])
plt.step(n_f,10**bins_f,linewidth=1.4,linestyle='-'\
	,c='blue',alpha=0.5)
x_f=y_f=[]
for i in range(len(bins_f)-1):
	x_f_tmp=np.arange(bins_f[i],bins_f[i+1],(\
		bins_f[int(num_bin_f/2)+1]-bins_f[int(\
			num_bin_f/2)])/50)
	for j in range(len(x_f_tmp)):
		y_f=np.append(y_f,n_f[i])
	x_f=np.append(x_f,x_f_tmp)
x_f=np.append(x_f[0],x_f)
x_f=np.append(x_f,x_f[len(x_f)-1])
y_f=np.append(0.0,y_f)
y_f=np.append(y_f,0.0)
plt.fill(y_f,10**(x_f),c='blue',alpha=0.2)
plt.plot(yline_f,10**arr_f,linewidth=1.4,\
	linestyle='dashed',c='blue')

plt.step(n_s,10**bins_s,linewidth=1.4,linestyle='-'\
	,c='red',alpha=0.5)
x_s=y_s=[]
for i in range(len(bins_s)-1):
	x_s_tmp=np.arange(bins_s[i],bins_s[i+1],(\
		bins_s[6]-bins_s[5])/50)
	for j in range(len(x_s_tmp)):
		y_s=np.append(y_s,n_s[i])
	x_s=np.append(x_s,x_s_tmp)
x_s=np.append(x_s[0],x_s)
x_s=np.append(x_s,x_s[len(x_s)-1])
y_s=np.append(0.0,y_s)
y_s=np.append(y_s,0.0)
plt.fill(y_s,10**(x_s),c='red',alpha=0.2)
plt.plot(yline_s,10**arr_s,linewidth=1.9,\
	linestyle='dashed',c='red')
plt.yscale('log')
plt.xticks([])
plt.yticks([])

plt.axis('off')
plt.xlim(0,0.65)
plt.ylim((10**46.5,1e55))


plt.subplot(gs[7:9,4:6])
xx=np.linspace(47,56,50)
yy=xx
plt.plot(10**xx,10**yy,c='black',linewidth=0.8,\
	linestyle='dashed')
qqplot(swift_lp_repo_ind_pl,fermi_lp_repo_ind,s=30\
	,alpha=0.8,marker='o',c='orange',edgecolors='k',\
	label='Swift-tot-pl')
qqplot(swift_lp_repo_ind_emp,fermi_lp_repo_ind,s=30\
	,alpha=0.7,marker='D',c='green',edgecolors='k',\
	label='Swift-tot-emp')
plt.xscale('log')
plt.yscale('log')
plt.xlim((10**49.3,1e55))
plt.ylim((10**49.3,1e55))
plt.xlabel('$Swift\;Quantiles\;\,log\;(L_{peak}\;\
	/\;erg\,s^{-1})$',fontsize='28')
plt.ylabel('$Fermi\;Quantiles\;\,log\;(L_{peak}\;\
	/\;erg\,s^{-1})$',fontsize='28')
plt.xticks([10**50,10**51,10**52,10**53,10**54,10**55]\
	,[50,51,52,53,54,55],fontsize='18')
plt.yticks([10**50,10**51,10**52,10**53,10**54,10**55]\
	,[50,51,52,53,54,55],fontsize='18')
plt.legend(loc='lower right',fontsize='24')
plt.twinx()
plt.twiny()
plt.xscale('log')
plt.yscale('log')
plt.xlim((10**49.3,1e55))
plt.ylim((10**49.3,1e55))
plt.xticks([10**50,10**51,10**52,10**53,10**54,\
	10**55,10**56],[])
plt.yticks([10**50,10**51,10**52,10**53,10**54,\
	10**55,10**56],[])

plt.tight_layout(pad=0.6, w_pad=0.5, h_pad=1.0)
plt.subplots_adjust(wspace=0,hspace=0)
plt.savefig('z_compare/plot.pdf')

运行结果: