I'm trying to set the order of a stacked histplot using seaborn. Below, then plot is fine but I'm hoping to alter the order so it reads Up, Down, Left, Right when reading left to right.
I get an error when trying to pass order or col_order.
raise AttributeError('{!r} object has no property {!r}'
AttributeError: 'Rectangle' object has no property 'order'
It works fine when not passing the order though.
import pandas as pd
import seaborn as sns
df = pd.DataFrame({
'Label' : ['A','B','C','B','B','C','C','B','B','A','C','A','B','A','C','A'],
'Item' : ['Up','Left','Up','Left','Down','Right','Up','Down','Right','Down','Right','Up','Up','Right','Down','Left'],
})
g = sns.histplot(data = df,
x = 'Item',
hue = 'Label',
#order = ['Up','Down','Left','Right'],
multiple = 'fill',
shrink = 0.8,
discrete = True,
legend = True,
)