How to add a string as the artist in matplotlib legend?
问题 I am trying to create a legend in a python figure where the artist is a string (a single letter) which is then labelled. For example I would like a legend for the following figure: import numpy as np import matplotlib.pyplot as plt import string N = 7 x = np.random.rand(N) y = np.random.rand(N) colors = np.random.rand(N) area = np.pi * (15 * np.random.rand(N))**2 plt.scatter(x, y, s=area, c=colors, alpha=0.5) for i,j in enumerate(zip(x,y)): plt.annotate(list(string.ascii_uppercase)[i],xy=j)