two legends

Hi,

How is it possible to add two legends in the same plot ?

Of course, if I try :
pt.legend(crv_lst,labels1,loc='upper right',shadow=True)
pt.legend(crv_lst,labels2,loc='upper left',shadow=True)

the first one is erased by the second one... :frowning:

Thanks in advance,

yves

路路路

--
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽(o o)
--------------------------------------------oOO--(_)--OOo-------
聽聽Yves Revaz
聽聽Laboratory of Astrophysics EPFL
聽聽Observatoire de Sauverny Tel : ++ 41 22 379 24 28
聽聽51. Ch. des Maillettes Fax : ++ 41 22 379 22 05
聽聽1290 Sauverny e-mail : Yves.Revaz@...2003...
聽聽SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------

Hi,

The legend of an axes instance is stored in axes.legend_ attribute.
And your second legend call will simply rebind this attribute to the
new legend object, and the first one is never drawn. You may make a
custom Axes class which can hold multiple legends. But if you want
something quick,

first_legend = pt.legend(crv_lst,labels1,loc='upper right',shadow=True)
pt.legend(crv_lst,labels2,loc='upper left',shadow=True)
gca().add_artist(first_legend)
draw()

It works for my quick test.

-JJ

路路路

On Wed, Aug 20, 2008 at 6:17 AM, Yves Revaz <yves.revaz@...2003...> wrote:

Hi,

How is it possible to add two legends in the same plot ?

Of course, if I try :
pt.legend(crv_lst,labels1,loc='upper right',shadow=True)
pt.legend(crv_lst,labels2,loc='upper left',shadow=True)

the first one is erased by the second one... :frowning:

Thanks in advance,

yves

--
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽(o o)
--------------------------------------------oOO--(_)--OOo-------
Yves Revaz
Laboratory of Astrophysics EPFL
Observatoire de Sauverny Tel : ++ 41 22 379 24 28
51. Ch. des Maillettes Fax : ++ 41 22 379 22 05
1290 Sauverny e-mail : Yves.Revaz@...2003...
SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi,

Here is a piece of code I recently used for plotting 2 different legends. This is not the most sexy code in the world but it works.

#axis and legend
axis([-0.1, 3.1, 0, 1], font)
xlabel(r'\textrm{relative error}', font)
ylabel(r'\textrm{cdf}', font)

rc('legend', numpoints=1)
leg1 = figlegend((lrep20[0], lrep50[0], lrep70[0]), (r'\textrm{reputation - 20\%}', r'\textrm{reputation - 50\%}', r'\textrm{reputation - 70\%}'), loc=(0.25, 0.11), prop=FontProperties(size='45', weight='bold'))
leg1.draw_frame(False)

rc('legend', numpoints=3)
leg2 = figlegend((lwithout20[0], lwithout50[0], lwithout70[0], lref[0]), (r'\textrm{20\%}', r'\textrm{50\%}', r'\textrm{70\%}', r'\textrm{reference}'), loc=(0.68, 0.08), prop=FontProperties(size='45', weight='bold'))
leg2.draw_frame(False)

Keep on Rockin'

Benoit

路路路

Le 20-ao没t-08 脿 12:17, Yves Revaz a 茅crit :

Hi,

How is it possible to add two legends in the same plot ?

Of course, if I try :
pt.legend(crv_lst,labels1,loc='upper right',shadow=True)
pt.legend(crv_lst,labels2,loc='upper left',shadow=True)

the first one is erased by the second one... :frowning:

Thanks in advance,

yves

--
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽(o o)
--------------------------------------------oOO--(_)--OOo-------
聽聽Yves Revaz
聽聽Laboratory of Astrophysics EPFL
聽聽Observatoire de Sauverny Tel : ++ 41 22 379 24 28
聽聽51. Ch. des Maillettes Fax : ++ 41 22 379 22 05
聽聽1290 Sauverny e-mail : Yves.Revaz@...2003...
聽聽SWITZERLAND Web : http://www.lunix.ch/revaz/
----------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Dr. Benoit Donnet
Universit茅 catholique de Louvain (UCL)
Ecole Polytechnique de Louvain (EPL) - D茅partement d'Ing茅nierie Informatique (INGI)
Place Sainte Barbe, 2
1348 Louvain-la-Neuve
Belgium
Phone: +32 10 47 87 18
Home page: http://inl.info.ucl.ac.be/donnet