Hello everyone I want to ask how to reduce the length of the legend line.
54 次查看(过去 30 天)
显示 更早的评论
Hello everyone I want to ask how to reduce the length of the legend line.
xlabel("b) Tiempo, t(s)");
ylabel("Elevation free surface, η(m)");
legend(["Coarse","Medium","Fine"],'Location','northwest',"NumColumns",2);
legend('boxoff');
0 个评论
采纳的回答
Abderrahim. B
2022-8-2
Hi!
Perhaps this:
figure
hold on
plot(1:10, randi(5,10,1))
plot(1:10, randi(10,10,1))
% Modify x1 and x2 based on your requirements
x1 = 5 ;
x2 = 5 ;
leg = legend('Plot1','Plot2');
leg.ItemTokenSize = [x1, x2];
Hope this helps
2 个评论
Abderrahim. B
2022-8-2
编辑:Abderrahim. B
2022-8-2
Maybe this workaround:
figure
hold on
plot(1:10, randi(5,10,1))
plot(1:10, randi(10,10,1))
% Modify x1 and x2 based on your requirements
x = [10, 10] ; % length
[legh, legObj, ~, ~] = legend('Plot1','Plot2' );
hlegObj = findobj(legObj,'type','line');
lineW = 2 ; % Line Width
set(hlegObj,'LineWidth',lineW);
legh.ItemTokenSize = x ;
legh.Box ='off' ;
更多回答(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!