ax.imshow(np.random.random((10, 10)), interpolation='none')
for label, xy in zip(labels, positions):
    ax.annotate(label, xy, xytext=(20, 20), size=15, textcoords=
        'offset points', bbox={'facecolor': 'white'}, arrowprops={
        'arrowstyle': '->'})
proxies = [create_proxy(item) for item in labels]
ax.legend(proxies, descriptions, numpoints=1, markerscale=2)
plt.show()

def create_proxy(label):
    line = matplotlib.lines.Line2D([0], [0], linestyle='none', mfc='black',
        mec='none', marker='$\\mathregular{{{}}}$'.format(label))
return line
main()
Полностью настраиваемая легенда в Matplotlib, Python