legend

Hello, I have some question on the legend.

    > the first is perhaps a bug:

    > I was trying something like:

    > plot([1,2,3],[2,3,4],label='toto') legend()

    > I can't obtain a legend, instead I have an error
    > message. So perhaps I didn't understand at all the
    > message I obtain with: help(legend) (it's possible with
    > my poor english :slight_smile: ) or there are a problem.

Yep, it's a bug. Replace the indicate line from axes.py

   loc = kwargs.gry('loc', 1)
                
with

   loc = kwargs.get('loc', 1)
                ^^^

Note to self: run pychecker more often.

    > second things: I would like to have the box create by the
    > legend commande behind my plot and not above because it
    > hide some of the point. Perhaps another solution is to
    > put the box bacground in "alpha mode" but I don't know
    > how to do this.

http://sourceforge.net/mailarchive/forum.php?thread_id=6039503&forum_id=33405

JDH

Hi John,

I tried:

> Yep, it's a bug. Replace the indicate line from
> axes.py
>
> loc = kwargs.gry('loc', 1)
> > with
>
> loc = kwargs.get('loc', 1)
> ^^^

That correct the problem with legend() but I have another problem and I think it's another bug (not sure) it's not possible to tell to matplotlib in this case o use the "loc" keywords more it's impossible to use this keywords. There are always an error message:
  File "<string>", line 3, in legend
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 1502, in legend
    self.legend_ = Legend(self, lines, labels, loc, **kwargs)
TypeError: __init__() got multiple values for keyword argument 'loc'

example:

plot ([2,3],[4,5])
legend(('toto'),loc=2)

I tried everything: loc='upper left', loc=0,1 , loc=(0,1), loc=2 etc. Nothing work but if I omit the " loc= " . It's ok and that explain probably why I cant do something like:

plot([1,2],[4,5],label='toto')
legend(loc='upper left')

Another strange thing I remark is:

if you are doing:

plot([1,2],[4,5])
legend(('toto'))

the text for the legend is vertical and not horizontal, that's work normally when we are using more than one argument.

Thank you very much for you fast answer and sorry for the second question I had to verify more precisely in the archival.

Nicolas

Hello Nicolas

Another strange thing I remark is:

if you are doing:

plot([1,2],[4,5])
legend(('toto'))

the text for the legend is vertical and not horizontal, that's work
normally when we are using more than one argument.

This happens because ('toto') is not a one-element list
but a string. If you write

  plot([1,2],[4,5])
  legend(('toto',))

instead it works as expected.

I hope this helps,
Jochen

···

On Wed, Dec 01, 2004 at 09:34:51AM -0500, Humufr wrote:
--
http://seehuhn.de/

Hi there,

apart from the "gry"-typo, the currect CVS-code really is in a broken state
after my patch was applied and half-way reverted back. (The python2.2-pop
problem)

Possible solutions:

* change "kwargs.get('xxx',def)" to "popd(kwargs,'xxx',def)" and add popd to
the import from cbook

* change "kwargs.get('xxx',def)" to "kwargs.pop('xxx',def)" (will not work for
Python 2.2

* change the last lines of Axes.legend according to:
         lines = flatten(lines)
+ kwargs["loc"] = loc
+ self.legend_ = Legend(self, lines, labels, **kwargs)
- self.legend_ = Legend(self, lines, labels, loc, **kwargs)
         return self.legend_

I guess, the first solution is, what will be done in the long run.

Ciao,
Nobbi

···

Am Mittwoch, 1. Dezember 2004 15:34 schrieb Humufr:

Hi John,

I tried:
> Yep, it's a bug. Replace the indicate line from
> axes.py
>
> loc = kwargs.gry('loc', 1)
>
> with
>
> loc = kwargs.get('loc', 1)
> ^^^

That correct the problem with legend() but I have another problem and I
think it's another bug (not sure) it's not possible to tell to
matplotlib in this case o use the "loc" keywords more it's impossible to
use this keywords. There are always an error message:
  File "<string>", line 3, in legend
  File "/usr/lib/python2.3/site-packages/matplotlib/axes.py", line 1502,
in legend
    self.legend_ = Legend(self, lines, labels, loc, **kwargs)
TypeError: __init__() got multiple values for keyword argument 'loc'

example:

plot ([2,3],[4,5])
legend(('toto'),loc=2)

I tried everything: loc='upper left', loc=0,1 , loc=(0,1), loc=2 etc.
Nothing work but if I omit the " loc= " . It's ok and that explain
probably why I cant do something like:

plot([1,2],[4,5],label='toto')
legend(loc='upper left')

Another strange thing I remark is:

if you are doing:

plot([1,2],[4,5])
legend(('toto'))

the text for the legend is vertical and not horizontal, that's work
normally when we are using more than one argument.

Thank you very much for you fast answer and sorry for the second
question I had to verify more precisely in the archival.

Nicolas

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
_________________________________________Norbert Nemec
         Bernhardstr. 2 ... D-93053 Regensburg
     Tel: 0941 - 2009638 ... Mobil: 0179 - 7475199
           eMail: <Norbert@...399...>