Closed
Description
Consider the following example:
import matplotlib.pyplot as plt
import numpy as np
fig,axes = plt.subplots()
line_A = axes.plot( np.random.random(10), label="foo" )[0]
line_B = axes.plot( np.random.random(10), label="bar" )[0]
line_C = axes.plot( np.random.random(10), label="quz" )[0]
lines = [line_A,line_B]
axes.legend( lines, [line.get_label() for line in lines] )
The last line needs to be this complicated since I get unwanted internal information if I just use axes.legend(lines)
. However, this seems like something legend
could do automatically: If I do not specify the handles for the legend, it extracts them from whatever I give it automatically.
This may be a duplicate of this request, but I am not sure.