I am trying to plot a groupby-pandas-dataframe in which I have a categorical variable by which I would like to order the bars.
A sample code of what I am doing:
import pandas as pd
df = {"month":["Jan", "Jan", "Jan","Feb", "Feb", "Mar"],
"cat":["High", "High", "Low", "Medium", "Low", "High"]}
df = pd.DataFrame(df)
df.groupby("month")["cat"].value_counts().unstack(0).plot.bar()
Which plots:
However, I would like to plot within each category the order to be Jan, Feb, March.
Any help on how to achieve this would be a appreciated.
Kind regards.


