Multicolumn legend
9 次查看(过去 30 天)
显示 更早的评论
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');
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 have tried the columnlegend application in Matlab File Exchange but I need that legend location to be SouthOutside, so it does not work for me.
0 个评论
采纳的回答
Daniel Shub
2011-11-26
MATLAB was not designed to produce publication quality graphs. People have hammered on MATLAB to push its capabilities. If neither columnlegend nor gridlegend can do it, there is likely no easy solution. You need to (1) loosen your constraints (e.g., choose a location other than SouthOutside), (2) be willing to code it your self, (3) create a plot as close as you can and then edit it with a graphics editing program (e.g., Iinkscape or GIMP), or (4) choose a program designed to make nice looking graphs (e.g., Pgfplots).
3 个评论
Scott
2013-5-9
"MATLAB was not designed to produce publication quality graphs."
What quality graphs was it designed to produce? Because it's certainly designed to produce graphs.
Daniel Shub
2013-5-13
@Scott there is a huge difference between software that is designed to produce graphs and one designed to produce publication quality graphs. Think about the difference between MS Word and MS Publisher, both are designed to produce text based documents, but only one is designed to produce publication quality text documents.
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!