首页 > 解决方案 > Pandas 条形图轴

问题描述

我正在制作下面链接的图表,我需要将属于数据顺序的 x 轴更改为 CCAA 或城市。我该怎么做?谢谢!

data = data.sort_values(by=['Cases'], ascending=False)

Combined = data2[['Cases','Deaths','Recovered']].plot(kind='bar',[enter image description here][1] figsize=(10, 10), legend=True, fontsize=13 )
plt.show

图形

数据

标签: pythonpandas

解决方案


指定xticks

data2[['Cases','Deaths','Recovered']].plot(
        kind='bar', figsize=(10, 10),
        legend=True, fontsize=13, 
        xticks=data2.CCAA)

推荐阅读