Rank: 608 based on 216 downloads (last 30 days) and 1 file submitted
photo

Adrian Cherry

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Adrian
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... 216 21
  • 3.86667
3.9 | 16 ratings
Comments and Ratings by Adrian 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's Files View all
Updated File Comment by Comments Rating
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 F, Benedikt

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!

09 Jan 2014 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry laoya

Great jobs, thanks!
I wish the function support 'Best' like the legend function of matlab.

Contact us