0

I have a simple bar plot in matplotlib for which I would like to add images instead of the text on the y axis. I want to load the images from the working directory. Some of the current code looks as follows:

animals = ['cat', 'dog', 'pig']
weight = [3, 10, 50] 
fig, ax = plt.subplots(1, 1)
colors = [red, blue]
p = ax.barh(x, y, height=0.8, alpha=1, color=colors)
ax.set_title("Animal Weight")
ax.bar_label(p, labels=y, padding=5)
plt.savefig("placement.png")

But the instead of the animal names on the y axis as labels I would like to have images. I am unsure how to approach this issue.

danonino
  • 11
  • 2
  • Yes thank you, it works if I hardcode it, I am just thinking maybe there is a more efficient method – danonino Sep 16 '21 at 17:18

0 Answers0