Rank: 722 based on 204 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... 204 18
  • 4.0
4.0 | 14 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
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.

10 Sep 2013 gridLegend - a multi column format for legends Plot a multicolumn format legend. Author: Adrian Cherry Byers, Edward

Doesn't work perfectly for subplots but...
I managed to get it to work reasonably well (on 1 occasion with an Area subplot) by...:
1) - Open gridLegend .m file and comment/delete line 273.
2) - If you are getting errors about Scribelegend, delete lines 278-284
3) - Specify a location (I used 'location','southoutside' )

Basically the issue with subplots (from what I can see) is that gridLegend is trying to control the 'gca' which doesn't seem to exist in subplots.

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.

Contact us