Matlab:减少图例中符号和标签之间的间距

mrs*_*tys 3 matlab legend legend-properties matlab-figure

在matlab中使用legend命令时,如何减少图例符号与其相应标签之间的水平距离?

示例代码:

Line1=plot(x1,y1,'s');
Line2=plot(x2,y2,'o');
Line3=plot(x3,y3,'^');
Leg=legend([Line1, Line2, Line3],...
           'Line1 text','Line2 text','Line3 text',...
           'Location','NorthEast');
Run Code Online (Sandbox Code Playgroud)

Moh*_*nia 5

您可以找到孩子们Leg,搜索那些Type设置text并重新定位的孩子.这是一个代码来说明如何做到这一点.它将它们向左移动0.2,相对于图例框.

ch = get(Leg, 'Children');
textCh = ch(strcmp(get(ch, 'Type'), 'text'));
for iText = 1:numel(textCh)
    set(textCh(iText), 'Position', get(textCh(iText), 'Position') + [-0.2 0 0])
end
Run Code Online (Sandbox Code Playgroud)