【发布时间】:2012-01-05 23:00:48
【问题描述】:
我希望能够创建一个图例以给出多个列(默认情况下,图例函数在 Matlab 中有一个唯一列)。例如,在下面编写的代码中,我需要在图例中添加三列,所以这将有两行和三列。
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');
我曾尝试在Matlab File Exchange 上使用名为gridlegend 的应用程序替换
legend(haxes,Ley,'Location','SouthOutside');
与
gridLegend(hplot,2,Ley,'Location','SouthOutside');
和
gridLegend(hplot,3,Ley,'Location','SouthOutside');
但是,由于图例的内容出现重叠和包容,得到的结果是无效的,对于情况3,是错误的。
P.D.我还在Matlab File Exchange 上尝试了名为columnlegend 的应用程序,但我需要将图例位置设置为SouthOutside,所以它对我不起作用。
【问题讨论】:
标签: matlab multiple-columns legend-properties