Rank: 567 based on 143 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, multi column, plot, legend, is there any way to a... 143 15
  • 3.8
3.8 | 11 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: Scott 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
03 May 2013 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Nicky

gridLegend doesn't seem to work when the figure contains subplots (it messes up the sizes of the subplots).
Is there any fix for this?

10 Apr 2013 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Jim

This is a nice improvement in capability over columnLegend. Unfortunately, despite turning off the ScribeLegendListeners properties, I find that when a figure is saved and later reopened, the legend reverts to single-column format. My code has two calls to saveas near the end, one to save the figure in .fig format, and one to save it as a .emf file. Both are afflicted with single-column disease.

21 Mar 2013 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Johnny

Is there any way to adjust the spacing between two columns? Thanks.

28 Feb 2013 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Pospiech, Matthias

The script fails for my patch plots completely:

Index exceeds matrix dimensions.

Error in gridLegend (line 206)
set(object_h(linenum), 'ydata', [height-position*sheight height-position*sheight]);

Error in testplot (line 204)
legHdl = gridLegend(hplot,2,ltext)

with hplot and ltext both of size 1x6

14 Jun 2011 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry G, J

Hi there, will this work on scatter plots? Thanks!

Top Tags Applied by Adrian
figure, legend, multi column, plot
Files Tagged 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, multi column, plot, legend, is there any way to a... 143 15
  • 3.8
3.8 | 11 ratings

Contact us