1
我希望能夠創建一個圖例來給出許多列(默認情況下,圖例函數在Matlab中具有唯一列)。例如,在下面編寫的代碼中,我需要在圖例中有三列,所以這將有兩行行和三列行。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(hplot,2,Ley,'Location','SouthOutside');
和
gridLegend(hplot,3,Ley,'Location','SouthOutside');
然而,重新更換
legend(haxes,Ley,'Location','SouthOutside');
稱爲gridlegend由於圖例的內容顯得重疊並且包含在內,所以得到的結論是無效的,因爲情況3是錯誤的。
P.D.我也嘗試過在Matlab File Exchange上叫做columnlegend的應用程序,但我需要那個傳說位置是SouthOutside,所以它不適用於我。