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()
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()