asa*_*lon 3 graphics matlab fonts matlab-figure
是否可以选择更改matlab创建的图例中的符号大小?我想要做的是增加符号,我在一个图中使用了3个点的4个散点而我没有找到方法.
谢谢.
Lui*_*ndo 10
要增加字体大小:获取所有类型的图例子项的句柄'text',并将其'Fontsize'属性设置为所需的值.
要增加标记大小:获取所有类型的图例子项的句柄'line',并将其'Markersize'属性设置为所需的值.
plot(1:10, 'o-');
hold on
plot(5:12, 'r*--'); %// example plots
h = legend('one plot', 'another plot', 'location', 'NorthWest'); %// example legend
ch = findobj(get(h,'children'), 'type', 'text'); %// children of legend of type text
set(ch, 'Fontsize', 14); %// set value as desired
ch = findobj(get(h,'children'), 'type', 'line'); %// children of legend of type line
set(ch, 'Markersize', 12); %// set value as desired
Run Code Online (Sandbox Code Playgroud)

图例中元素的组织现在是不同的.以下作品:
plot(1:10, 'o-');
hold on
plot(5:12, 'r*--'); %// example plots
[~, objh] = legend({'one plot', 'another plot'}, 'location', 'NorthWest', 'Fontsize', 14);
%// set font size as desired
objhl = findobj(objh, 'type', 'line'); %// objects of legend of type line
set(objhl, 'Markersize', 12); %// set marker size as desired
Run Code Online (Sandbox Code Playgroud)
小智 5
如果有人像我一样来到这里寻找一种更改散点图图例标记大小的方法:对于线图,您需要“补丁”类型的对象(2017b),而不是“线”类型的对象。
objhl = findobj(objh, 'type', 'patch'); % objects of legend of type patch
set(objhl, 'Markersize', 12); % set marker size as desired
Run Code Online (Sandbox Code Playgroud)