I have a df (called pivot_df) that I want to plot as a bar chart. The df has multiple columns, and the indexes, which are years, represent the x-values. Each index should have 5 bars representing relevant columns, but some columns have missing values (NaN) for certain years. When I use pivot_df.plot(kind='bar'), the resulting bar plot has spaces between bars for years with missing values:
I would like to find a solution to create adjacent bars for each year, so the bars for each year are next to each other without any spaces. Is there a way to achieve this?
This is the layout of the pivot_df I'm working with:
any suggestions or helps would be appreciated.