C
C Barrington-Leigh
"""
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()
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()