这里放上我比较喜欢的一种条形图设置,使用的是之前爬取的重庆地区链家二手房数据,数据如下:
链接:https://pan.baidu.com/s/17CMwUAdseO8tJWHEQiA8_A
提取码:dl2g
importpandas as pdimportmatplotlib.pyplot as pltimportseaborn as sns
df= pd.read_csv('lianjia_utf.csv')
df.head()
sns.set(style='white', font_scale=1.2)#保证可以显示中文字体
plt.rcParams['font.sans-serif']='simhei'
#设置字体大小
font1 = {'family' : 'simhei','weight' : 'normal','size' : 18,}#使用数据透视表
region_pivot = pd.pivot_table(df, values='Price', index='Region', aggfunc='count').reset_index().sort_values(ascending=True,by='Price')
f, ax= plt.subplots(figsize=(8,6))