Hello everyone I want to ask how to reduce the length of the legend line.
50 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Juan David Parra Quintero
am 2 Aug. 2022
Kommentiert: Juan David Parra Quintero
am 4 Aug. 2022
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 Kommentare
Akzeptierte Antwort
Abderrahim. B
am 2 Aug. 2022
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 Kommentare
Abderrahim. B
am 2 Aug. 2022
Bearbeitet: Abderrahim. B
am 2 Aug. 2022
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' ;
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!