[SciPy-User] matplotlib: Simple legend code no longer works after upgrade to Ubuntu 11.10

Oops; I just posted this to comp.lang.python, but I wonder whether

matplotlib questions are supposed to go to scipy-user?

How about matplotlib-users@lists.sourceforge.net? I’ve cc’ed to that list.

Warren

···

On Mon, Dec 12, 2011 at 7:05 PM, C Barrington-Leigh <cpblpublic@…287…> wrote:

Here it is:

“”"

Before I upgraded to 2.7.2+ / 4 OCt 2011, the following code added a

comment line to an axis legend using matplotlib / pylab.

Now, the same code makes the legend appear “off-screen”, ie way

outside the axes limits.

Can anyone help? And/or is there a new way to add a title and footer

to the legend?

Thanks!

“”"

from pylab import *

plot([0,0],[1,1],label=‘Ubuntu 11.10’)

lh=legend(fancybox=True,shadow=False)

lh.get_frame().set_alpha(0.5)

from matplotlib.offsetbox import TextArea, VPacker

fontsize=lh.get_texts()[0].get_fontsize()

legendcomment=TextArea(‘extra comments here’,

textprops=dict(size=fontsize))

show()

Looks fine here

lh._legend_box = VPacker(pad=5,

                     sep=0,

                     children=[lh._legend_box,legendcomment],

                     align="left")

lh._legend_box.set_figure(gcf())

draw()


SciPy-User mailing list

SciPy-User@…177…

http://mail.scipy.org/mailman/listinfo/scipy-user

Although this is quite an old post, one need to set the location again.

e.g.,

lh._loc = 2

Regards,

-JJ

···

On Wed, Dec 14, 2011 at 12:09 AM, Warren Weckesser <warren.weckesser@...1036...> wrote:

On Mon, Dec 12, 2011 at 7:05 PM, C Barrington-Leigh <cpblpublic@...287...> > wrote:

Oops; I just posted this to comp.lang.python, but I wonder whether
matplotlib questions are supposed to go to scipy-user?

How about matplotlib-users@lists.sourceforge.net? I've cc'ed to that list.

Warren

Here it is:
"""
Before I upgraded to 2.7.2+ / 4 OCt 2011, the following code added a
comment line to an axis legend using matplotlib / pylab.
Now, the same code makes the legend appear "off-screen", ie way
outside the axes limits.

Can anyone help? And/or is there a new way to add a title and footer
to the legend?

Thanks!
"""

from pylab import *
plot([0,0],[1,1],label='Ubuntu 11.10')
lh=legend(fancybox=True,shadow=False)
lh.get_frame().set_alpha(0.5)

from matplotlib.offsetbox import TextArea, VPacker
fontsize=lh.get_texts()[0].get_fontsize()
legendcomment=TextArea('extra comments here',
textprops=dict(size=fontsize))
show()
# Looks fine here
lh._legend_box = VPacker(pad=5,
sep=0,
children=[lh._legend_box,legendcomment],
align="left")
lh._legend_box.set_figure(gcf())
draw()

_______________________________________________
SciPy-User mailing list
SciPy-User@...177...
http://mail.scipy.org/mailman/listinfo/scipy-user

------------------------------------------------------------------------------
Systems Optimization Self Assessment
Improve efficiency and utilization of IT resources. Drive out cost and
improve service delivery. Take 5 minutes to use this Systems Optimization
Self Assessment. http://www.accelacomm.com/jaw/sdnl/114/51450054/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options