调整legend中marker大小

方法1(有效)

% Create the plot
ax = axes(); 
hold on
h(1) = plot(linspace(1,5,25), rand(1,25), 'ro', 'DisplayName', 'foo');
h(2) = plot(1:5, rand(1,5), 'b-', 'DisplayName', 'bar');
% copy the objects
hCopy = copyobj(h, ax); 
% replace coordinates with NaN 
% Either all XData or all YData or both should be NaN.
set(hCopy(1),'XData', NaN', 'YData', NaN)
set(hCopy(2),'XData', NaN', 'YData', NaN)
% Note, these lines can be combined: set(hCopy,'XData', NaN', 'YData', NaN)
% To avoid "Data lengths must match" warning, assuming hCopy is a handle array, 
% use arrayfun(@(h)set(h,'XData',nan(size(h.XData))),hCopy)
% Alter the graphics properties
hCopy(1).MarkerSize = 15; 
hCopy(1).LineWidth = 2;
hCopy(2).LineWidth = 3; 
% Create legend using copied objects
legend(hCopy)

https://www.mathworks.com/matlabcentral/answers/50250-how-can-i-change-the-marker-size-in-legend

方法2(画图有效,保存文件无效)

% Create a legend with 3 entries
[h,icons] = legend('Entry 1','Entry 2','Entry 3');
% Find the 'line' objects
icons = findobj(icons,'Type','line');
% Find lines that use a marker
icons = findobj(icons,'Marker','none','-xor');
% Resize the marker in the legend
set(icons,'MarkerSize',20);

你可能感兴趣的:(调整legend中marker大小)