I have a Pandas dataframe with four columns; the first is a centretype (x axis) and I want the rest of the columns to be displayed as side by side columns for each centretype by year. I am not sure what I'm doing wrong, as I am getting only the values for 2019 but I want 2018 and 2017 displayed too.
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



dflikedf = pd.DataFrame(np.random.rand(5,3), columns=[2018, 2019, 2020], index=list("ABCDE"))and run your code I get the desired output, namely this. This means that you're either not using the data you think you do, or that you're using a specific pandas version with a bug in it.