我有一个包含四列的Pandas数据框;第一个是中心类型(x轴),我希望其余各列按年份显示为每种中心类型的并排列。我不确定自己在做什么错,因为我只获得了2019年的值,但我也想显示2018年和2017年。
df = c2
colors = ['steelblue','forestgreen','salmon']
ax = df.plot(kind='bar', color=colors, width=0.7, align='center', stacked=False, rot=60, figsize=(12,6), legend=False, zorder=3)
from matplotlib.ticker import FuncFormatter, MaxNLocator
ax.yaxis.set_major_locator(MaxNLocator(integer=True))
plt.grid(zorder=0)
#plt.legend(loc='upper center', bbox_to_anchor=(0.5, -0.2))
plt.xlabel("Type of centre")
plt.ylabel("Number")
plt.title("")
ax.spines['bottom'].set_color('gainsboro')
ax.spines['top'].set_color('white')
ax.spines['right'].set_color('white')
ax.spines['left'].set_color('gainsboro')
ax.yaxis.label.set_color('black')
ax.xaxis.label.set_color('black')
ax.title.set_color('black')
ax.patch.set_facecolor('white')
plt.savefig('images/figure1.png', dpi=300, facecolor=ax.get_facecolor(), transparent=True, bbox_inches='tight', pad_inches=0.1)
plt.show()
data.shape