I am trying to generate a frequency plot at different time frames with each time frame consists of four conditions and two possible outcomes, High or low. I can use hue to separate the four conditions but I also want to separate each condition with outcomes. Here's my data-
import pandas as pd
import seaborn as sns
exp = {'Time':['2hrs', '2hrs', '2hrs','2hrs','2hrs', '2hrs', '2hrs','4hrs','4hrs','4hrs','4hrs','4hrs','4hrs','4hrs','4hrs' ],
'Condition':['A+','A-','B+','B-','B+','B-','B+','A+','A-','B+','B-','A+','A-','A+','A-',],
'Outcome': ['High', 'Low','High','High', 'Low','High', 'Low','High','High','High','Low', 'Low','Low','Low', 'High']}
df = pd.DataFrame(data=exp)
df.head()
hue_order = ['A+', 'A-', 'B+', 'B-']
ax = sns.countplot(data=df, x='Time' , hue='Condition', hue_order=hue_order, palette='Set1')
plt.legend(title='', loc='upper left', bbox_to_anchor=(1,1))
What I got is-
But what I want is to further split each column proportional to how many "High" or "Low" are there for that specific condition and time frame. For example, at 4hrs there are three A+ of which one is with "High" outcome and remaining two are with "Low" outcomes. So, I want to shade 1/3 with dark red and 2/3 with light red.
Not sure if I described the problem clearly.