[Matplotlib-users] removing a line with its label from an axes

2009-06-30 Thread Magnus Benjes
Hello, I know how to remove a line from an axes. But a I also want to remove the label of the line from the legend of the axes. In the sample code you can see two labels in the legend, while there is only one line in the axes left. import numpy as N from matplotlib.pyplot import * x =

Re: [Matplotlib-users] removing a line with its label from an axes

2009-06-30 Thread C Lewis
Try calling legend() again once you've changed the lines; in ipython - pylab, this x = linspace(-10, 10, 101) sub = subplot(111) plot(x, x**2, label=x^2) plot(x, x**3, label=x^3) legend() #Two lines, two legend entries sub.lines[0].remove() #One line, two legend entries