1.seaborn绘制boxplot
'''使用seaborn方法:'''
fig1,axes=plt.subplots(2,1,figsize=(20,16))
sns.barplot(x=q1data_top20_f1['city'],y=q1data_top20_f1['_id_nor'],ax=axes[0])
axes[0].set_title('知友数量top 20',fontsize=20)
axes[0].set_xlabel('城市',fontsize=30)
axes[0].set_ylabel('知友数量',fontsize=30)
axes[0].legend("知友数量城市分布")
fig2,axes2=plt.subplots(figsize=(20,16))
sns.barplot(x=q1data_top20_f2['city'],y=q1data_top20_f2['知友密度_nor'],ax=axes[1])
axes[1].set_title('知友密度top 20',fontsize=20)
axes[1].set_xlabel('城市',fontsize=30)
axes[1].set_ylabel('知友密度',fontsize=30)
axes[1].legend("知友密度城市分布")
2.使用matplotlib绘制:
'''使用matplotlib方法:'''
fig,axes=plt.subplots(2,2,figsize=(20,16))
q1data_top20_f1.plot.bar(ax=axes[0,0])
axes[0,0].set_xticklabels(q1data_top20_f1['city'],rotation=315)
q1data_top20_f2.plot.bar(ax=axes[0,1])
axes[0,1].set_xticklabels(q1data_top20_f2['city'],rotation=315)
q1data_top20_f1.plot.bar(ax=axes[1,1])
axes[1,1].set_xticklabels(q1data_top20_f1['city'],rotation=315)
q1data_top20_f2.plot.bar(ax=axes[1,0])
axes[1,0].set_xticklabels(q1data_top20_f2['city'],rotation=315)