import matplotlib.pyplot as plt
#中文设置问题
plt.rcParams['font.sans-serif'] = ['SimHei']
fig1=plt.figure(num=1,figsize=(12,8))
y1=q1data_top20_sl[result_cols[0]]
plt.bar(range(20),
y1,
width=0.8,
facecolor='cyan',
edgecolor='k',
align='center',
tick_label=q1data_top20_sl['city']
)
plt.title('知友数量TOP20\n',fontsize=20)
plt.xlabel('城市',fontsize=20)
plt.ylabel('知友数量',fontsize=20)
#坐标轴刻度的字体大小
plt.tick_params(labelsize=13)
#给图形添加数据标签
for i,j in zip(range(20),y1):
plt.text(i, j+0.2, '%.0f' %j, ha='center', va= 'bottom',fontsize=12)