My seaborn plot is shown below. Is there a way to add the info in the flag
column (which will always be a single character or empty string) in the center (or top) of the bars? Hoping there is an answer which would not need redoing the plot as well.
This answer seems to have some pointers but I am not sure how to connect it back to the original dataframe to pull info in the flag
column.
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame([
['C', 'G1', 'gbt', 'auc', 0.7999, "†"],
['C', 'G1', 'gbtv2', 'auc', 0.8199, "*"],
['C', 'G1', 'gbt', 'pr@2%', 0.0883, "*"],
['C', 'G1', 'gbt', 'pr@10%', 0.0430, ""],
['C', 'G2', 'gbt', 'auc', 0.7554, ""],
['C', 'G2', 'gbt', 'pr@2%', 0.0842, ""],
['C', 'G2', 'gbt', 'pr@10%', 0.0572, ""],
['C', 'G3', 'gbt', 'auc', 0.7442, ""],
['C', 'G3', 'gbt', 'pr@2%', 0.0894, ""],
['C', 'G3', 'gbt', 'pr@10%', 0.0736, ""],
['E', 'G1', 'gbt', 'auc', 0.7988, ""],
['E', 'G1', 'gbt', 'pr@2%', 0.0810, ""],
['E', 'G1', 'gbt', 'pr@10%', 0.0354, ""],
['E', 'G1', 'gbtv3','pr@10%',0.0454, ""],
['E', 'G2', 'gbt', 'auc', 0.7296, ""],
['E', 'G2', 'gbt', 'pr@2%', 0.1071, ""],
['E', 'G2', 'gbt', 'pr@10%', 0.0528, "†"],
['E', 'G3', 'gbt', 'auc', 0.6958, ""],
['E', 'G3', 'gbt', 'pr@2%', 0.1007, ""],
['E', 'G3', 'gbt', 'pr@10%', 0.0536, "†"],
], columns=["src","grp","model","metric","val","flag"])
cat = sns.catplot(data=df, x="grp", y="val", hue="model", kind="bar", sharey=False,
col="metric", row="src")
plt.show()