I would like to add labels to my sns
histogram. I've used plt.text
but it's colliding with the edges of the frame.
How can I prevent it from doing that? Or - is there a better way to add labels?
Thanks.
plt.figure(figsize=(7, 4))
hist = sns.histplot(x='y', data=data, hue='y', palette=palette, legend=False)
for p in hist.patches:
x = p.get_x() + p.get_width() / 2
if p.get_height() != 0:
txt = plt.text(x=x, y=p.get_height() + 1000, s=p.get_height(), ha='center')