2

I'm working on a demonstration for a dimensionality reduction method where the data (images) gets projected in a 2D space and labels are added like that:

# (x[i], y[i]) are the embedding coordinates of the i'th sample
plt.plot(x, y, 'ro')
labels = ['image {0}'.format(i+1) for i in range(len(x))]
for label, xpt, ypt in zip(labels, x, y):
    plt.annotate(
        label,
        xy = (xpt, ypt), xytext = (-20, 20),
        textcoords = 'offset points', ha = 'right', va = 'bottom')
        # some styles not related to the question
plt.show()

This approach suffers from having to look up every single image in order to get an idea if the algorithm produced reasonable results.

Is there any way to replace the text labels with (thumbnails of) the images that are actually being used? (It's only for presentation purposes so there won't be huge junks of data cluttering up everything)

Peter
  • 946
  • 9
  • 23
  • 2
    Semi-duplicate of: http://stackoverflow.com/a/22570069/325565 or http://stackoverflow.com/a/4860777/325565 . I may be misunderstanding your question, though, so I'm holding off on the close vote. At any rate, hopefully you'll find that general approach useful. – Joe Kington Jan 06 '15 at 18:22
  • Do you already have the thumbnails generated and available on your file system? – Matthew Turner Jan 06 '15 at 18:22
  • @JoeKington No misunderstanding here, these answers are just right; sorry for the dublicate, but I couldn't find them when I was browsing SO earlier. (Should I just delete this question?) – Peter Jan 06 '15 at 19:19
  • @Peter - No need to delete it. I'll mark it as a duplicate, though, if that's okay. – Joe Kington Jan 06 '15 at 19:20
  • @mtpain Yes, they are already present as 1D arrays for the algorithm as well – Peter Jan 06 '15 at 19:25
  • @JoeKington Of course – Peter Jan 06 '15 at 19:25

0 Answers0