Matlab绘图 图例legend 太长,怎么减小指示线的长度

您所在的位置:网站首页 word图表的图例太长了 Matlab绘图 图例legend 太长,怎么减小指示线的长度

Matlab绘图 图例legend 太长,怎么减小指示线的长度

2024-07-11 13:44| 来源: 网络整理| 查看: 265

来源

绘图时,稍微减小文字已经不能正常放下图例,想通过调整图例指示线段长度缩减整个图例长度。

方法一

参考matlab官方论坛

leg = legend('Plot1','Plot2',...); leg.ItemTokenSize = [x1,x2]; By default x1=30 and x2=18 so put larger or smaller numbers as x1,x2 to increase or decrease the legend line size.

自己的代码

lgd = legend({'Theore. SM--------F', 'Theore. SM--------',... 'Experi. SM--------', 'Experi. SM--------'}); lgd.ItemTokenSize = [15,18]; % 这一句调整图例示例线段长度 lgd.Position = [0.562 0.735 0.4 0.25]; lgd.FontName = 'Arial'; lgd.FontSize = 7; set(gca, 'Position', [0.565 0.125 0.435 0.6])

在这里插入图片描述

方法二

单独运行这段代码没问题,但是多个曲线时报错

h1 = plot(1:10); [hh,icons,plots,txt] = legend({'Line 1'}); p1 = icons(1).Position; icons(1).Position = [0.3 p1(2) 0]; icons(2).XData = [0.05 0.2];

在这里插入图片描述



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3