First, this is another topic, so please, change the subject of the
message so it doesn't get messed up with others (and possible help
lost in the process).

Now, you are indeed plotting one dot at the time and generating a
label for it. If you don't want that, you have to plot the whole list
at the time:


x=[rand() for i in xrange(10)]
y=[rand() for i in xrange(10)]

scatter(x,y, label='points')
legend()
show()

where the definition of x includes a list comprehension (equivalent at
"for i in xrange(10): x.append(rand())" ).

On another topic, people are not usually fan of using  from MODULEX
import *, as it can turn into poor code and name collisions. It is
nicer if you write "import pylab as plt", and refer to the functions
as plt.scatter and so on.


Regards.

On Wed, Jun 13, 2012 at 9:21 PM, Steven Boada <bo...@physics.tamu.edu> wrote:
> List,
>
> I'm making a scatter plot using a for loop. Here's a simple example..
>
> for i in range(10):
>     x=rand()
>     y=rand()
>     scatter(x,y,label='point')
>
> legend()
> show()
>
>
> When you do this, you get a legend entry for every single point. In this
> case, I get 9 entries in my legend.
>
> Is there a way to only get a single entry? I have looked into creating
> the legends by hand, but I'm not having much luck. Googling, only turned
> up a single example of someone else with the same problem.
>
> Help me list, you're my only hope.
>
> Steven
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to