Title for legend

Hello,
a friend point me to [1] asking if there's a way to add a title to
legend without applying this patch. Well, my answer was "not that I
know of" then I start wondering if there's a reason this patch was not
applied and there's a plan to do it anytime soon.

[1] http://www.mail-archive.com/matplotlib-users%40lists.sourceforge.net/msg05678.html

Thanks for considering,

···

--
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi

Jae Joon -- will you review this and apply it if it looks like a good
addition to you

Thanks,
JDH

···

On Fri, Feb 13, 2009 at 3:31 AM, Sandro Tosi <morph@...12...> wrote:

Hello,
a friend point me to [1] asking if there's a way to add a title to
legend without applying this patch. Well, my answer was "not that I
know of" then I start wondering if there's a reason this patch was not
applied and there's a plan to do it anytime soon.

[1] http://www.mail-archive.com/matplotlib-users%40lists.sourceforge.net/msg05678.html

John and Sandro,

I just had a quick look at the patch. The patch is for older version
of the mpl, and I couldn't test it yet. Anyhow, it should be straight
forward to port it to the new legend class. I'll work on it.

Meanwhile, below is a little code one may use to put the legend title
w/o modifying the mpl.

-JJ

plot([1,2,3])
plot([2,1,3])
legend(["test", "test2"])

fig = gcf()
ax = gca()

from matplotlib.offsetbox import TextArea, VPacker

mylegend=ax.get_legend()
legendtitle=TextArea( "Legend Title", textprops=dict(size=20))
mylegend._legend_box = VPacker(pad=5,
                               sep=0,
                               children=[legendtitle, mylegend._legend_box],
                               align="center")
mylegend._legend_box.set_figure(fig)

draw()

···

On Fri, Feb 13, 2009 at 7:20 AM, John Hunter <jdh2358@...149...> wrote:

On Fri, Feb 13, 2009 at 3:31 AM, Sandro Tosi <morph@...12...> wrote:

Hello,
a friend point me to [1] asking if there's a way to add a title to
legend without applying this patch. Well, my answer was "not that I
know of" then I start wondering if there's a reason this patch was not
applied and there's a plan to do it anytime soon.

[1] http://www.mail-archive.com/matplotlib-users%40lists.sourceforge.net/msg05678.html

Jae Joon -- will you review this and apply it if it looks like a good
addition to you

Thanks,
JDH

I just committed the support of the legend title into the trunk.
See the legend_demo3.py.
Regards,

-JJ

···

On Fri, Feb 13, 2009 at 3:10 PM, Jae-Joon Lee <lee.j.joon@...149...> wrote:

John and Sandro,

I just had a quick look at the patch. The patch is for older version
of the mpl, and I couldn't test it yet. Anyhow, it should be straight
forward to port it to the new legend class. I'll work on it.

Meanwhile, below is a little code one may use to put the legend title
w/o modifying the mpl.

-JJ

plot([1,2,3])
plot([2,1,3])
legend(["test", "test2"])

fig = gcf()
ax = gca()

from matplotlib.offsetbox import TextArea, VPacker

mylegend=ax.get_legend()
legendtitle=TextArea( "Legend Title", textprops=dict(size=20))
mylegend._legend_box = VPacker(pad=5,
                              sep=0,
                              children=[legendtitle, mylegend._legend_box],
                              align="center")
mylegend._legend_box.set_figure(fig)

draw()

On Fri, Feb 13, 2009 at 7:20 AM, John Hunter <jdh2358@...149...> wrote:

On Fri, Feb 13, 2009 at 3:31 AM, Sandro Tosi <morph@...12...> wrote:

Hello,
a friend point me to [1] asking if there's a way to add a title to
legend without applying this patch. Well, my answer was "not that I
know of" then I start wondering if there's a reason this patch was not
applied and there's a plan to do it anytime soon.

[1] http://www.mail-archive.com/matplotlib-users%40lists.sourceforge.net/msg05678.html

Jae Joon -- will you review this and apply it if it looks like a good
addition to you

Thanks,
JDH