modified legend appears out of view! It didn't used to. MWE included.

C

cpbl

I seem to be using
Python 2.7.2+
(latest update of Ubuntu). The following code used to work nicely, but
now gives me an unreadable legend. The legend is showing up mostly out
of view below and to the left of the figure. Does that happen for you?
Is there a regression bug, or am I doing something wrong?
The MWE below is adapted from a function I wrote to allow addition of
extra comments within a legend box below the normal legend details.
Thanks for any help!
Chris

!/usr/bin/python

import pylab as plt

from matplotlib.offsetbox import TextArea, VPacker
comments='foodlefish'
plt.figure(1)
plt.plot([1,2],[3,4], label='test')
lh=plt.legend(fancybox=True,shadow=False,title='Foodle',loc='best')
if lh:
lh.get_frame().set_alpha(0.5)
fontsize=lh.get_texts()[0].get_fontsize()
legendcomment=TextArea('\n'.join(comments),
textprops=dict(size=fontsize))
lh._legend_box = VPacker(pad=5,
sep=0,
children=[lh._legend_box,legendcomment],
align="right") # Or should it be centre?
lh._legend_box.set_figure(plt.gcf())

plt.show()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top