I want to write custom values above my bars in barplot which I made using sns.barplot. My custom values are available in the same DataFrame under another column. This question has been answered elsewhere however, they do not consider Hue. How would you write custom values sourced in the same DataFrame when Hue is defined?
DataFrame:
XData | YData | Type | Label |
---|---|---|---|
X | 123 | TypeA | 001 |
Y | 234 | TypeA | 010 |
X | 345 | TypeB | 100 |
Y | 567 | TypeB | 000 |
here is my plot:
MyBarPlot = sns.barplot(data=DataFrame, x="XData", y="YData",hue="Type",width=0.8, errorbar=('ci', 95))
DataFrameGrouped = DataFrame.groupby(['XData','YData']).label.mean()
for container in MyBarPlot .containers:
MyBarPlot.bar_label(container[0], labels=DataFrameGrouped, padding=3, fmt='%.1f')