与图例标签的字体大小分开控制图例标记的大小

时间:2020-02-04 14:24:46

标签: matlab plot

我需要与图例标签的字体大小分开控制图例中的标记。受this上一个问题的启发,我在Matlab 2016a中使用了以下代码:

x = 1:10;
plot(x, 1*x, 'o')
hold on
plot(x, 2*x, 's')
h_legend = legend({'one','two'});
objhl = findobj(h_legend, 'type', 'line'); % objects of legend of type patch
set(objhl, 'Markersize', 99); % set marker size as desired

但是,无论我输入什么代替99,都没有区别。如果将“行”更改为“补丁”,那也没有任何区别。我猜这个问题来自objhl实际上为空的事实:

>> objhl = findobj(h_legend, 'type', 'patch')
objhl = 
  0x0 empty GraphicsPlaceholder array.

有什么想法吗?非常感谢!

1 个答案:

答案 0 :(得分:0)

好吧,所以差异似乎在于结果是分配给“传奇”输出的第一个还是第二个变量。如果第五行替换为

[~, h_legend] = legend({'one','two'});

那么结果就是预期的结果。

相关问题