2011-04-15 57 views

回答

5

要创建一个双列图例,一般的共识似乎是您需要创建两个独立的图例并手动将它们并排放置。从discussion here简化了解决方案。

x = 1:10; 
y1 = rand(1, 10); 
y2 = rand(1, 10); 

h1 = plot(x, y1, '-'); 
hold on 
h2 = plot(x, y2, '-.r'); 

ah1 = gca; 
ah2 = axes('position',get(gca,'position'), 'visible','off'); 

legend(ah1, h1, 'Location', [0.5 0.85 0.15 0.05], 'y1') 
legend(ah2, h2, 'Location', [0.7 0.85 0.15 0.05], 'y2') 
+0

这个工程创建多列的传说!这个答案中最重要的技巧是''Location',[0.5 0.85 0.15 0.05]'后者的向量具有以下解释:'[Position_Right_in_pct,Position_Top_in_pct,Horizo​​ntal_Stretch Vertical_Stretch]' – Ufos 2016-02-29 09:54:54