%matplotlib inline
import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
plt.figure(figsize=(15,7))
#第一个图表
plt.subplot(121)
plt.title('(a)1',fontsize=12)#标题,并设定字号大小
df = pd.DataFrame(np.random.rand(50,2),columns=['A','B'])
#data.boxplot(vert=False,grid=False,patch_artist=True,meanline=True,showmeans=True,showfliers=False,sym='.',figsize=(12,8),fontsize=15,boxprops = {'color':'orangered','facecolor':'pink'})
ax=df.boxplot(vert=True,showfliers=False,grid=False,figsize=(8,8),widths=0.8)
ax.set_xlabel("Type Transition",fontdict={'family' : 'Times New Roman', 'size' : 14})
ax.set_ylabel("Percentage(%)",fontdict={'family' : 'Times New Roman', 'size' : 14})
#ax=plt.gca()
#ax为两条坐标轴的实例
#ax.xaxis.set_major_locator(x_major_locator)
#把x轴的主刻度设置为1的倍数
#ax.set_xticklabels(labels=["CN - CN","CN - LK"],rotation=300)
plt.subplot(122)
plt.title('(b) 2',fontsize=12)#标题,并设定字号大小
df = pd.DataFrame(np.random.rand(50,2),columns=['C','D'])
#data.boxplot(vert=False,grid=False,patch_artist=True,meanline=True,showmeans=True,showfliers=False,sym='.',figsize=(12,8),fontsize=15,boxprops = {'color':'orangered','facecolor':'pink'})
ax=df.boxplot(vert=True,showfliers=False,grid=False,figsize=(8,8),widths=0.8)
ax.set_xlabel("Type Transition",fontdict={'family' : 'Times New Roman', 'size' : 14})
ax.set_ylabel("Percentage(%)",fontdict={'family' : 'Times New Roman', 'size' : 14})
#ax.set_xticklabels(labels=["CN - CN","CN - LK"],rotation=300)
plt.savefig('boxplot.jpg',dpi=1000, bbox_inches='tight')
plt.show()#显示图像