After playing around with my data, grouping and unstacking I got to the following Series :
day type meat veg vegan
0 2017-07-02 Evening 62.0 11.0 16.0
1 2017-07-03 Afternoon 54.0 6.0 16.0
2 2017-07-03 Evening 1.0 0.0 0.0
3 2017-07-04 Morning 26.0 2.0 2.0
4 2017-07-04 Afternoon 47.0 5.0 7.0
5 2017-07-04 Evening 46.0 7.0 14.0
6 2017-07-05 Morning 16.0 4.0 9.0
7 2017-07-05 Afternoon 36.0 9.0 24.0
8 2017-07-05 Evening 44.0 6.0 20.0
9 2017-07-06 Afternoon 47.0 8.0 16.0
10 2017-07-06 Evening 36.0 6.0 18.0
11 2017-07-07 Morning 36.0 4.0 8.0
12 2017-07-07 Afternoon 23.0 3.0 5.0
13 2017-07-07 Evening 50.0 12.0 16.0
14 2017-07-08 Morning 21.0 0.0 9.0
15 2017-07-08 Afternoon 21.0 2.0 7.0
16 2017-07-08 Evening 48.0 8.0 16.0
Now what I would like to do is to plot a stacked bar where on the y axis the total number, and on the x axis the meals (Evening, afternoon, Morning), grouped by day.
At the moment the best I managed is
.plot(kind='bar',stacked=True,rot=60)
that gives me a stacked plot but the information about the meals is lost. Ideally I'd like to have :
| | | | | | -------------------------------------- .... Mor Aft Eve Mor Aft Eve .... ----------- ----------- 01/07 02/07
Update 1
Getting inspiration from Multiple stacked bar plot with pandas and plotting evening, mornings and afternoon separately I get something better still not satisfactory.
fig, ax = plt.subplots()
gdf.loc[gdf['day'] == 'Morning'].plot(kind='bar',stacked=True,rot=60,ax=ax, position=1.5, width=0.1)
gdf.loc[gdf['day'] == 'Afternoon'].plot(kind='bar',stacked=True,rot=60,ax=ax, position=0.5, width=0.1)
gdf.loc[gdf['day'] == 'Evening'].plot(kind='bar',stacked=True,rot=60,ax=ax, position=-0.5, width=0.1)
plt.show()
I imagine this can all be done more elegantly without drawing separate subplots and then stitching them together
Update 2
re-indexing the data I can get a better plot, but still not what I'm aiming for, that is grouping labels that is
| | | | | | -------------------------------------- .... Mor Aft Eve Mor Aft Eve .... ----------- ----------- 01/07 02/07