Rank: 639 based on 234 downloads (last 30 days) and 1 file submitted
photo

Adrian Cherry

E-mail

Personal Profile:

 

Watch this Author's files

 

Files Posted by Adrian Cherry
Updated   File Tags Downloads
(last 30 days)
Comments Rating
13 Jan 2011 Screenshot gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry figure, plot, legend, multi column, is there any way to a... 234 22
  • 3.875
3.9 | 17 ratings
Comments and Ratings by Adrian Cherry View all
Updated File Comments Rating
07 Feb 2011 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry

Hi Robin,

Sorry to hear that my routine has trouble with the long legend titles, I've had a quick look at it and I can see where the problem lies. It's possible to apply a quick fix it but then it messes up the short titles.

My first suggestion in the specific example you have posted is to just use the standard legend function in MATLAB, if you apply the 'orientation','horizontal' pair to legend then you'll get a one row, two column legend.

Obviously this won't help if you want a 2x2 legend with long titles. In this case for the minute you'll have to tweak the code.

At line 232

% resize the data aspect ratio to match the new shape.
set(legend_h,'dataaspectratio',[width/gd gd/numpercolumn 1]);

You'll need to tweak the aspect ratio, in your case factor the y-axis by 4.
% resize the data aspect ratio to match the new shape.
set(legend_h,'dataaspectratio',[width/gd 4*gd/numpercolumn 1]);

I'm still looking at improving the calculation so that it'll do it automatically but for the minute I hope this helps.

Regards
Adrian

18 May 2010 linelabel Identify a plotted line by clicking on it. Author: Michelle Hirsch

Very useful.

I tweaked it slightly so that it would work with bar charts as well (R2008a)

lines 131 and 182 now read
if strcmp(htype,'line') || strcmp(htype,'hggroup')

Regards

Adrian

Comments and Ratings on Adrian Cherry's Files View all
Updated File Comment by Comments Rating
06 Nov 2014 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Mahdi Ebrahimian

Hi Adrian,
Thanks for the nice function.
I want to have a row legend (three columns one row) but when I put column number equal to three I get an error message.
"Can't work out what sort of legend we've got - sorry bailing out"

Any suggestions to fix this?

04 Aug 2014 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Todd

Very easy to use and helpful. Thanks.

25 Jul 2014 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Benedikt F

Did not work for a figure containing both error bar and x-y plots

10 Jul 2014 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry James

Works very well, except when the figure is saved as a fig file. When the saved file is opened, the legend has reverted to single column. Recommendations for how to fix this issue appreciated.

21 Feb 2014 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Amanda

Hi, I love this function! My one big issue is that I sometimes find it hard to define a handle for the plotted data. Especially for compound graphs like a bar chart with error bars.

I get error for too many output arguments.

I am new to matlab so I hope someone could help me out here. Thank you!

Contact us