I would like to be able to create a legend to have a number of columns given (for default the legend function has an unique column in Matlab). In the code written below, for example, I need three columns in the legend so this would have two rows lines and three column lines.
X = 0:pi/100:0.25*pi;
Y1 = sin(X);
Y2 = cos(X);
Y3 = tan(X);
Y4 = 0.5;
fh = figure('toolbar','none','menubar','none','Units','characters');
Pan1 = uipanel(fh,'Units','normalized','Position',[0 0 0.5 1],'title',...
'Panel1');
Pan2 = uipanel(fh,'Units','normalized','Position',[0.5 0 0.5 1],'title',...
'Panel2');
haxes = axes('Parent',Pan2,'Units', 'normalized','Position',...
[0.125 0.1 0.75 0.75]);
hplot = plot(haxes,X,Y1,X,Y2,X,Y3,X,Y4);
xlabel(haxes,'Time (second)');
ylabel(haxes,'Amplitude (meter)');
title(haxes,'Trigonometric functions');
Ley = {'Sine function','Cosine function','Tangent function','Constant'};
legend(haxes,Ley,'Location','SouthOutside');
I have tried to use the application called gridlegend on the Matlab File Exchange replacing
legend(haxes,Ley,'Location','SouthOutside');
with
gridLegend(hplot,2,Ley,'Location','SouthOutside');
and
gridLegend(hplot,3,Ley,'Location','SouthOutside');
However, the results obtained are not valid because of the legend's contents appears overlapped and inclusive, for the case 3, is wrong.
P.D. I also have tried the application called columnlegend on the Matlab File Exchange but I need that legend location to be SouthOutside, so it does not work for me.