From: Paul K. <np...@gm...> - 2012-06-13 20:11:10
|
I have a routine where I start outside the loop with and empty sequence > leg = [] then add at each iteration the label > leg.append('mylabel') then call legend with the sequence at the end > legend(leg) I think I once truncated the list and got part only > legend(leg[:2]) It depends on what you want to do. Paul On Wed, Jun 13, 2012 at 8:56 PM, Mike Kaufman <mc...@gm...> wrote: > On 6/13/12 3:23 PM, Steven Boada wrote: >> Whoops, I forgot to change the subject. Sorry list. >> >> 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. > > Perhaps not exactly what you want, but an answer is don't use a loop: > > x = rand(10) > y = rand(10) > scatter(x,y, label='points') > legend() > draw() > show() > > Of course if you want to color each point differently, then this won't work. > > M > > > ------------------------------------------------------------------------------ > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- * * * * * * * * http://www.mssl.ucl.ac.uk/~npmk/ * * * * Dr. N.P.M. Kuin (np...@ms...) phone +44-(0)1483 (prefix) -204256 (work) -276110 (home) mobile +44(0)7806985366 skype ID: npkuin Mullard Space Science Laboratory – University College London – Holmbury St Mary – Dorking – Surrey RH5 6NT– U.K. |