【注】详情请参阅 MatLab help 文档。
legend 函数可以在 MatLab 的坐标区按曲线的绘制顺序添加对应曲线的图例。
legend
legend(label1,···,labelN)
legend(labels)
legend(subset,___)
legend(target,___)
legend(___,Name,Value)
legend(bkgd)
lgd = legend(___)
[lgd,icons,plots,text] = legend(___)
legend(vsbl)
legend('off')
‘Location’,lct :lct 为相对于坐标区的位置,其可选取值如下表: 值 说明 ‘north’ 坐标区中的顶部 ‘south’ 坐标区中的底部 ‘east’ 坐标区中的右侧 ‘west’ 坐标区中的左侧 ‘northeast’ 坐标区中的右上角(二维坐标区的默认值) ‘northwest’ 坐标区中的左上角 ‘southeast’ 坐标区中的右下角 ‘southwest’ 坐标区中的左下角 ‘northoutside’ 坐标区的上方 ‘southoutside’ 坐标区的下方 ‘eastoutside’ 坐标区外的右侧 ‘westoutside’ 坐标区外的左侧 ‘northeastoutside’ 坐标区外的右上角(三维坐标区的默认值) ‘northwestoutside’ 坐标区外的左上角 ‘southeastoutside’ 坐标区外的右下角 ‘southwestoutside’ 坐标区外的左下角 ‘best’ 坐标区内与绘图数据冲突最少的地方 ‘bestoutside’ 坐标区外的右上角(当图例为垂直方向)或坐标区的下方(当图例为水平方向) ‘none’ 由 Position 属性决定,可使用 Position 属性在自定义位置显示图例
‘Orientation’,ornt :ornt 为图例的d堆叠方向(‘vertical’(默认)| ‘horizontal’)
‘TextColor’,[R G B] | 常用颜色 : 指定文本颜色,默认颜色为 [0 0 0]
‘Color’,[R G B] | 常用颜色 : 指定文本颜色,默认颜色为 [1 1 1]
‘EdgeColor’,常用颜色 : 指定文本颜色,默认颜色为 [0.15 0.15 0.15]
‘Box’,‘on’(默认)| ‘off’ :指定图例框轮廓是否显示。
‘LineWidth’,Value :设置轮廓框的宽度(默认值为 0.5,Value 为以磅为单位的正值)
‘FontSize’,Value :指定字体大小(默认大小取决于系统和区域设置,Value 为大于 0 的标量值,以磅为单位)
‘NumColumns’,Value :指定图例项的显示列数(默认为 1,Value 为正整数)
‘NumColumnsMode’,‘auto’(默认)| ‘manual’ :设置 NumColumns 值的选择模式
‘Position’,[left bottom width height] :设置图例框位置和大小,四元素向量中 left 和 bottom 指定从图窗左下角到图例左下角的距离,width 和 height 分别指定图例框的宽度和高度
‘Units’,Value :设置位置单位,Value 可选取值如下表:【注】所有的位置大小都是从图窗左下角开始进行测量的。 Value 说明 ‘normalized’(默认值) 相对于图窗进行归一化(图窗左下角映射到(0,0),右上角映射到(1,1) ‘inches’ 英寸 ‘centimeters’ 厘米 ‘characters’ 基于默认系统字体的字符大小(字符宽度 = 字母 x 的宽度,字符高度 = 两个文本行的基线之间的距离) ‘points’ 磅(1 磅 = 1/72 英寸) ‘pixels’ 像素
‘AutoUpdate’,‘on’(默认)| ‘off’ :设置是否自动更新图例项以反映坐标区的当前状态。
‘Interpreter’,‘tex’(默认)| ‘latex’ | ‘none’ :设置解释文本字符的方式。
‘FontName’,支持的字体名称 | ‘FixedWidth’ :设置字体(必须选择系统支持的字体,默认字体取决于系统和区域设置,FixWidth 为等宽字体)
‘FontSize’,Value :设置字体大小为 Value(Value 为大于 0 的标量值,以磅为单位)
‘FontWeight’,‘normal’(默认)| ‘bold’ :设置字体粗细。
‘FontAngle’,‘normal’(默认)| ‘italic’ :设置字体是否倾斜。
'boxon'(默认)| 'boxoff'
。前者表示显示图例背景和轮廓,后者表示不显示图例背景和轮廓。
'hide' | 'show' | 'toggle'
,依次对应隐藏图例、显示图例或创建图例(图里不存在时)、切换图例可见性。