How to change the bar length in a bar graph legend?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
There was already a similar question asked - and answered - in 2009 (link), but the solution no longer works in the newer releases.
Thanks in advance!
0 Kommentare
Antworten (1)
Yongan
am 10 Nov. 2023
Verschoben: the cyclist
am 10 Nov. 2023
It could be changed by using 'ItemTokenSize' parameter. Please refer to the sample code below:
% Create a bar graph
x = 1:5;
y = [10 15 8 12 9];
bar(x, y);
% Get the handle to the legend object
legendHandle = legend('Data');
% Set the desired length of the bar in the legend axes
desiredLength = 20; % Modify this value as needed
% Set the desired height of the bar in the legend axes
desiredHeight = 10; % Modify this value as needed
% Adjust the ItemTokenSize property of the legend
set(legendHandle, 'ItemTokenSize', [desiredLength desiredHeight]);
0 Kommentare
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!