legend bug?

hi all,

following my last post, i found what seems to me to be a bug in the legend handling of scatter plots. suppose i have:

scatter([1,2,3],[1,2,3], label=“nolegend”)

i then want to color some subset of these points in a different color, or plot them using a different marker size, etc. so i do:

scatter([1],[1],c=‘r’)

then if i do:

legend(‘my point’, numpoints=1)

the legend is still displayed with 3 points… even if i directly set rcParams[‘legend.numpoints’] = 1, it still behaves this way. any idea how to fix this?

thank you

It can be tricky to give you a correct answer without knowing what
version of mpl you're using. The legend for the scatter plot has been
added rather recently so my answer below may not work for you.

Anyhow, this seems to be a bug in the documentation, not the code.
The legend for scatter plot has its own properties to control the
number of points, which is "scatterpoints".

So, try

legend(scatterpoints=1)

As a side note,

legend('my point', numpoints=1)

The first argument should be a list, but I guess this could be just a typo.

scatter([1,2,3],[1,2,3], label="_nolegend_")

You'd better not use this (setting the label) if you're explicitly
giving the legend labels. I recommend you to stick with either

scatter([1,2,3],[1,2,3], label="_nolegend_")
scatter([1],[1],c='r', label="mypoints")
legend(scatterpoints=1)

or

s1=scatter([1,2,3],[1,2,3])
s2=scatter([1],[1],c='r')
legend([s2], ["mypoints"], scatterpoints=1)

-JJ

···

On Wed, Mar 11, 2009 at 6:39 PM, per freem <perfreem@...287...> wrote:

hi all,

following my last post, i found what seems to me to be a bug in the legend
handling of scatter plots. suppose i have:

scatter([1,2,3],[1,2,3], label="_nolegend_")

i then want to color some subset of these points in a different color, or
plot them using a different marker size, etc. so i do:

scatter([1],[1],c='r')

then if i do:

legend('my point', numpoints=1)

the legend is still displayed with 3 points... even if i directly set
rcParams['legend.numpoints'] = 1, it still behaves this way. any idea how to
fix this?

thank you

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users