Placing a 'title' inside a legend

Hi,

I'd like to place something like a 'title' inside a legend's box. In my
specific case, I have a legend with 5 entries, arranged in 5 columns, so
they're horizontally next to each other in one row. Now what I'd like to
have is inside the legend's box a first row (above the legend entries),
where I can write some text.

Any ideas?

Cheers, Andreas.

Hi Andreas,

2012/7/27 Andreas Hilboll <lists@...3067...>:

Hi,

I'd like to place something like a 'title' inside a legend's box. In my
specific case, I have a legend with 5 entries, arranged in 5 columns, so
they're horizontally next to each other in one row. Now what I'd like to
have is inside the legend's box a first row (above the legend entries),
where I can write some text.

Any ideas?

The keyword 'title' in legend
(http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend)
should work.

Francesco

···

Cheers, Andreas.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Andreas,

2012/7/27 Andreas Hilboll <lists@...3067...>:

Hi,

I'd like to place something like a 'title' inside a legend's box. In my
specific case, I have a legend with 5 entries, arranged in 5 columns, so
they're horizontally next to each other in one row. Now what I'd like to
have is inside the legend's box a first row (above the legend entries),
where I can write some text.

Any ideas?

The keyword 'title' in legend
(http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend)
should work.

Almost embarassingly simple ... however: It looks like the title is in a
smaller font size than the other legend texts. Do I have some control
about the font size of the legend's title? Couldn't find anything in the
plt.legend docstring (I'm on 1.1.1).

Cheers, A.

Hi Andreas,

2012/7/27 Andreas Hilboll <lists@...3067...>:

Hi Andreas,

2012/7/27 Andreas Hilboll <lists@...3067...>:

Hi,

I'd like to place something like a 'title' inside a legend's box. In my
specific case, I have a legend with 5 entries, arranged in 5 columns, so
they're horizontally next to each other in one row. Now what I'd like to
have is inside the legend's box a first row (above the legend entries),
where I can write some text.

Any ideas?

The keyword 'title' in legend
(http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend)
should work.

Almost embarassingly simple ... however: It looks like the title is in a
smaller font size than the other legend texts. Do I have some control
about the font size of the legend's title? Couldn't find anything in the
plt.legend docstring (I'm on 1.1.1).

try:
l = ax.legend( patches, labels, ..., title="legend title")
t = l.get_title() #get the text object containing the title
t.set_fontsize(30) #set the font size

you can merge the last two lines together l.get_title().set_fontsize(30)

Francesco

···

Cheers, A.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Francesco,

I'd like to place something like a 'title' inside a legend's box. In
my
specific case, I have a legend with 5 entries, arranged in 5 columns,
so
they're horizontally next to each other in one row. Now what I'd like
to
have is inside the legend's box a first row (above the legend
entries),
where I can write some text.

Any ideas?

The keyword 'title' in legend
(http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.legend)
should work.

Almost embarassingly simple ... however: It looks like the title is in a
smaller font size than the other legend texts. Do I have some control
about the font size of the legend's title? Couldn't find anything in the
plt.legend docstring (I'm on 1.1.1).

try:
l = ax.legend( patches, labels, ..., title="legend title")
t = l.get_title() #get the text object containing the title
t.set_fontsize(30) #set the font size

you can merge the last two lines together l.get_title().set_fontsize(30)

Thanks - that did the trick :slight_smile:

Cheers, A.