15.3.3.4图例对象属性

的属性legend对象(详见传奇):

类别:

回调执行 | 布局 | 图例外观 | 对象标识 | 对象位置 | 文本外观 

回调执行

广告
itemhitfcn: def. [](0x0)

当单击图例项时执行的回调函数。详见回调部分 .

回调函数必须具有以下原型fcn (hlegend, evnt)这里的hlegend是图例对象句柄,并且evnt是一个具有以下字段的结构体:

Peer

与单击的项目关联的打印对象的句柄。

广告
Region

可能是"icon""label"这取决于项目的哪个部分被点击。

广告
SelectionType

什么之中的一个"normal", "extend", "open""alt"详见图形"selectiontype" .

广告
Source

图例对象的句柄。

广告
EventName

名称为"ItemHit".

广告
广告

布局

广告
autoupdate: "off" | {"on"}

控制将对象添加到对等轴(或从对等轴删除对象)时是否自动更新图例项的数量。例如

## Create a single plot with its legend.
figure ();
plot (1:10);
legend ("Slope 1");
## Add another plot and specify its displayname so that
## the legend is correctly updated.
hold on;
plot ((1:10) * 2, "displayname", "Slope 2");
## Stop automatic updates for further plots.
legend ("autoupdate", "off");
plot ((1:10) * 3);
广告
numcolumns: scalar integer, def. 1

控制图例项布局中使用的列数。例如

figure ();
plot (rand (30));
legend ("numcolumns", 3);

背景numcolumns也迫使numcolumnsmode属性设置为"manual".

广告
orientation: "horizontal" | {"vertical"}

控制图例项是垂直排列(按列排列)还是水平排列(按行排列)。

广告

图例外观

广告
box: "off" | {"on"}

控制图例是否有环绕框。

广告
color: colorspec, def. [1 1 1]

图例背景的颜色。详见颜色规格.

广告
edgecolor: colorspec, def. [0.1500 0.1500 0.1500]

控制图例轮廓的颜色。

广告

对象标识

广告
title: graphics handle

标题文本对象的图形句柄。

广告

对象位置

广告
location: "best" | "bestoutside" | "east" | "eastoutside" | "none" | "north" | {"northeast"} | "northeastoutside" | "northoutside" | "northwest" | "northwestoutside" | "south" | "southeast" | "southeastoutside" | "southoutside" | "southwest" | "southwestoutside" | "west" | "westoutside"

控制图例的位置。

广告
position: four-element vector

指定图例的位置(不包括其标题)。向量的四个元素是左下角的坐标以及图例的宽度和高度。更改此属性还会切换"location""none".

广告
units: "centimeters" | "characters" | "inches" | {"normalized"} | "pixels" | "points"

用于解释的单位"position"属性

广告

文本外观

广告
fontangle: "italic" | {"normal"}

控制字体是斜体还是普通字体。

广告
fontname: string, def. "*"

用于文本呈现的字体的名称。设置此属性时,文本呈现引擎将在系统中搜索匹配的字体。如果没有找到,则使用默认的无衬线字体(与默认字体相同"*"

编程注意事项:在本机不使用FontConfig的系统上(除了Linux以外的所有系统),字体缓存是在安装Octave时构建的。你需要跑步system ("fc-cache -fv")安装新字体后手动操作。

广告
fontsize: scalar, def. 9

用于文本呈现的字体大小。详见fontunits属性背景fontsize也迫使fontsizemode属性设置为"manual".

广告
fontunits: "centimeters" | "inches" | "normalized" | "pixels" | {"points"}

用于解释的单位"fontsize"属性

广告
fontweight: "bold" | {"normal"}

控制用于文本呈现的基本字体的变体。

广告
string: string | cell array of strings

图例项的标签列表。例如

figure ();
plot (rand (20));
## Let legend choose names automatically
hl = legend ();
## Selectively change some names
str = get (hl, "string");
str(1:5:end) = "Garbage";
set (hl, "string", str);
广告
textcolor: colorspec, def. [0 0 0]

控制图例项的文本字符串的颜色。

广告

版权所有 © 2024-2025 Octave中文网

ICP备案/许可证号:黑ICP备2024030411号-2