exclude something from legend

Hello all,

Is there a way to tell MPL that something I plotted (like a series of
Line2D, to create a grid) should not be considered for the legend?

I'm plotting a lot of things, and because of these objects (without
label), I always got these msgs:

/usr/lib/pymodules/python2.6/matplotlib/axes.py:4014: UserWarning: No
labeled objects found. Use label='...' kwarg on individual plots.
  warnings.warn("No labeled objects found. "

Tks

···

--
Prof. Carlos Henrique Grohmann - Geologist D.Sc.
Institute of Geosciences - Univ. of São Paulo, Brazil
http://www.igc.usp.br/pessoais/guano
http://lattes.cnpq.br/5846052449613692
Linux User #89721
________________
Can’t stop the signal.

Hi Carlos,

···

On Thu, Aug 26, 2010 at 04:49, Carlos Grohmann <carlos.grohmann@...287...> wrote:

Hello all,

Is there a way to tell MPL that something I plotted (like a series of
Line2D, to create a grid) should not be considered for the legend?

I'm plotting a lot of things, and because of these objects (without
label), I always got these msgs:

/usr/lib/pymodules/python2.6/matplotlib/axes.py:4014: UserWarning: No
labeled objects found. Use label='...' kwarg on individual plots.
warnings.warn("No labeled objects found. "

I always use the following set of commands to get costumize my legend:

**************************************
legendEntries=[] # list of plots that are going to be in
the legend
legendText=[] # list of text messages for the legend

thisPlot = plot(x,y,'b*') # a plot command

legendEntries.append(thisPlot) # only do this for the plots you want
to add to the legend
legendText.append("legend text") # only this for the plots you want
to add to the legend

lgd = legend(legendEntries,legendText,numpoints=1,prop=props,loc='upper
right') # example of how to draw the legend

**************************************

Hope this helps,

Tinne

You can also leave out the label, or in a loop like this,
conditionally assign a label of '_nolegend_', which suppresses adding
it to the legend. This example shows how the different options work:

import numpy as np
import matplotlib.pyplot as plt
x1,y1 = np.random.rand(2,10)
x2,y2 = np.random.rand(2,10)
x3,y3 = np.random.rand(2,10)
x4,y4 = np.random.rand(2,10)
plt.plot(x1, y1, label='first')
plt.plot(x2, y2) # No label, so not included
plt.plot(x3, y3, label='_nolegend_') # Actively suppress
plt.plot(x4, y4, label='fourth')
plt.legend() # Only shows lines 'first' and 'fourth'

Ryan

···

On Thu, Aug 26, 2010 at 1:55 AM, Tinne De Laet <tinne.delaet@...2824...> wrote:

Hi Carlos,

On Thu, Aug 26, 2010 at 04:49, Carlos Grohmann > <carlos.grohmann@...287...> wrote:

Hello all,

Is there a way to tell MPL that something I plotted (like a series of
Line2D, to create a grid) should not be considered for the legend?

I'm plotting a lot of things, and because of these objects (without
label), I always got these msgs:

/usr/lib/pymodules/python2.6/matplotlib/axes.py:4014: UserWarning: No
labeled objects found. Use label='...' kwarg on individual plots.
warnings.warn("No labeled objects found. "

I always use the following set of commands to get costumize my legend:

**************************************
legendEntries=[] # list of plots that are going to be in
the legend
legendText=[] # list of text messages for the legend

thisPlot = plot(x,y,'b*') # a plot command

legendEntries.append(thisPlot) # only do this for the plots you want
to add to the legend
legendText.append("legend text") # only this for the plots you want
to add to the legend

lgd = legend(legendEntries,legendText,numpoints=1,prop=props,loc='upper
right') # example of how to draw the legend

**************************************

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Many thanks Tinne.

That did it.

···

On Thu, Aug 26, 2010 at 03:55, Tinne De Laet <tinne.delaet@...2824...> wrote:

Hi Carlos,

On Thu, Aug 26, 2010 at 04:49, Carlos Grohmann > <carlos.grohmann@...287...> wrote:

Hello all,

Is there a way to tell MPL that something I plotted (like a series of
Line2D, to create a grid) should not be considered for the legend?

I'm plotting a lot of things, and because of these objects (without
label), I always got these msgs:

/usr/lib/pymodules/python2.6/matplotlib/axes.py:4014: UserWarning: No
labeled objects found. Use label='...' kwarg on individual plots.
warnings.warn("No labeled objects found. "

I always use the following set of commands to get costumize my legend:

**************************************
legendEntries=[] # list of plots that are going to be in
the legend
legendText=[] # list of text messages for the legend

thisPlot = plot(x,y,'b*') # a plot command

legendEntries.append(thisPlot) # only do this for the plots you want
to add to the legend
legendText.append("legend text") # only this for the plots you want
to add to the legend

lgd = legend(legendEntries,legendText,numpoints=1,prop=props,loc='upper
right') # example of how to draw the legend

**************************************

Hope this helps,

Tinne

--
Prof. Carlos Henrique Grohmann - Geologist D.Sc.
Institute of Geosciences - Univ. of São Paulo, Brazil
http://www.igc.usp.br/pessoais/guano
http://lattes.cnpq.br/5846052449613692
Linux User #89721
________________
Can’t stop the signal.