如何使用matplotlib作为标签

时间:2015-01-06 18:18:29

标签: python matplotlib

我正在进行降维方法的演示,其中数据(图像)在2D空间中投影,标签的添加方式如下:

# (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()

这种方法不得不查找每个图像,以便了解算法是否产生了合理的结果。

有没有办法用实际使用的图像(缩略图)替换文本标签? (它仅用于演示目的,所以不会让数据变得混乱)

0 个答案:

没有答案