Consider following code:
t=0:.01:(2*pi);
y=[sin(t);sin(t-pi/12);sin(t-pi/6);sin(t-pi/4)];
figure(1)
clf
subplot(6,1,5)
plot(t,y)
xlim([0 2*pi])
legend('1','2','3','4')
It produces following figure:
Is there a way to change the legend to a 2-column lay-out? So it would be
--- 1 --- 3
--- 2 --- 4
instead of
--- 1
--- 2
--- 3
--- 4
so the legend boundary lined would not cross the graph boundary lines.
I found the gridLegend
script, but I prefer to code it directly.
gridLegend
is best – AmylosegridLegend
is doing and implement it yourself. – Nonproductivelegend
statement. – AnnouncementgridLegend
. There's really no point re-inventing the wheel. – Aldolegend('1','2','3','4','Orientation','horizontal')
so the legend doesn't cross the border of the axes? This might not solve your question but could be a straight-forward solution to your problem. – Scheming