MATLAB Answers

Ross
2

LEGEND TITLE

Asked by Ross
on 15 Feb 2012
Latest activity Commented on by Eyal Ben-Hur on 23 Jun 2017
I am using the following command line to change the text of a figure's default legend:
legend('820mm','750mm','680mm','585mm','470mm','Location','NE');
but would like to add what the measurements relate to in a LEGEND TITLE, eg. 'Panel sizes (mm)'. Then I don't have to have 'mm' on every line and don't have to say what they measure elsewhere.
Shouldn't be difficult but can't find it in help. Would somebody kindly help please?
Thank you.

  0 Comments

Sign in to comment.

1 Answer

Andrew Newell
Answer by Andrew Newell
on 15 Feb 2012
 Accepted Answer

There is a lot of information buried in layers of handle graphics. You can do the following:
hleg = legend('820mm','750mm','680mm','585mm','470mm','Location','NE');
htitle = get(hleg,'Title');
set(htitle,'String','Panel sizes (mm)')
Use get(htitle) to see a lot of other properties you can manipulate.

  4 Comments

Show 1 older comment
Ali
on 24 Aug 2016
It seems this is not working anymore on R2015b.
Eddy Barratt on 26 Aug 2016
I believe there are easier options in more recent versions of MATLAB. Certainly the R2016a online documentation for legend suggests that you can simply call
title(hleg, 'Panel sizes (mm)').
Eyal Ben-Hur on 23 Jun 2017
If you get in trouble while setting the title, take a look here

Sign in to comment.