File: plot-legendproperties.texi

package info (click to toggle)
octave 10.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 145,388 kB
  • sloc: cpp: 335,976; ansic: 82,241; fortran: 20,963; objc: 9,402; sh: 8,756; yacc: 4,392; lex: 4,333; perl: 1,544; java: 1,366; awk: 1,259; makefile: 659; xml: 192
file content (224 lines) | stat: -rw-r--r-- 7,927 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
@c DO NOT EDIT!  Generated automatically by genpropdoc.m.

@c Copyright (C) 2014-2025 The Octave Project Developers
@c
@c See the file COPYRIGHT.md in the top-level directory of this
@c distribution or <https://octave.org/copyright/>.
@c
@c This file is part of Octave.
@c
@c Octave is free software: you can redistribute it and/or modify it
@c under the terms of the GNU General Public License as published by
@c the Free Software Foundation, either version 3 of the License, or
@c (at your option) any later version.
@c
@c Octave is distributed in the hope that it will be useful, but
@c WITHOUT ANY WARRANTY; without even the implied warranty of
@c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
@c GNU General Public License for more details.
@c
@c You should have received a copy of the GNU General Public License
@c along with Octave; see the file COPYING.  If not, see
@c <https://www.gnu.org/licenses/>.

Properties of @code{legend} objects (@pxref{XREFlegend,,legend}):

@subsubheading Categories:

@ref{XREFlegendcategoryCallbackExecution, , @w{Callback Execution}}@: | @ref{XREFlegendcategoryLayout, , @w{Layout}}@: | @ref{XREFlegendcategoryLegendAppearance, , @w{Legend Appearance}}@: | @ref{XREFlegendcategoryObjectIdentification, , @w{Object Identification}}@: | @ref{XREFlegendcategoryObjectPosition, , @w{Object Position}}@: | @ref{XREFlegendcategoryTextAppearance, , @w{Text Appearance}}@: 

@anchor{XREFlegendcategoryCallbackExecution}
@subsubheading Callback Execution

@table @asis

@anchor{XREFlegenditemhitfcn}
@prindex legend itemhitfcn
@item @code{itemhitfcn}: def. @code{[](0x0)}
Callback function which is executed when a legend item is clicked.  @xref{Callbacks, , @w{Callbacks section}}.

The callback function must have the following prototype @code{fcn (hlegend, evnt)}, where @code{hlegend} is the legend object handle and @code{evnt} is a structure with the following fields:
@table @code
@item Peer
Handle of the plot object to which the clicked item is associated.
@item Region
May be @qcode{"icon"} or @qcode{"label"} depending on which part of the item is clicked.
@item SelectionType
One of @qcode{"normal"}, @qcode{"extend"}, @qcode{"open"}, or @qcode{"alt"}.  @xref{XREFfigureselectiontype, , @w{Figure @qcode{"selectiontype"}}}.
@item Source
Handle of the legend object.
@item EventName
Name is @qcode{"ItemHit"}.
@end table

@end table

@anchor{XREFlegendcategoryLayout}
@subsubheading Layout

@table @asis

@anchor{XREFlegendautoupdate}
@prindex legend autoupdate
@item @code{autoupdate}: @qcode{"off"} | @{@qcode{"on"}@}
Control whether the number of legend items is updated automatically when objects are added to (or deleted from) the peer axes.
For example:
@example
@group
## 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);
@end group
@end example


@anchor{XREFlegendnumcolumns}
@prindex legend numcolumns
@item @code{numcolumns}: scalar integer, def. @code{1}
Control the number of columns used in the layout of the legend items.  For example:
@example
@group
figure ();
plot (rand (30));
legend ("numcolumns", 3);
@end group
@end example
Setting @code{numcolumns} also forces the @code{numcolumnsmode} property to be set to @qcode{"manual"}.


@anchor{XREFlegendorientation}
@prindex legend orientation
@item @code{orientation}: @qcode{"horizontal"} | @{@qcode{"vertical"}@}
Control whether the legend items are arranged vertically (column-wise) or horizontally (row-wise).

@end table

@anchor{XREFlegendcategoryLegendAppearance}
@subsubheading Legend Appearance

@table @asis

@anchor{XREFlegendbox}
@prindex legend box
@item @code{box}: @qcode{"off"} | @{@qcode{"on"}@}
Control whether the legend has a surrounding box.


@anchor{XREFlegendcolor}
@prindex legend color
@item @code{color}: colorspec, def. @code{[1   1   1]}
Color of the legend background.  @xref{Colors, , colorspec}.


@anchor{XREFlegendedgecolor}
@prindex legend edgecolor
@item @code{edgecolor}: colorspec, def. @code{[0.1500   0.1500   0.1500]}
Control the color of the legend outline.

@end table

@anchor{XREFlegendcategoryObjectIdentification}
@subsubheading Object Identification

@table @asis

@anchor{XREFlegendtitle}
@prindex legend title
@item @code{title}: graphics handle
Graphics handle of the title text object.

@end table

@anchor{XREFlegendcategoryObjectPosition}
@subsubheading Object Position

@table @asis

@anchor{XREFlegendlocation}
@prindex legend location
@item @code{location}: @qcode{"best"} | @qcode{"bestoutside"} | @qcode{"east"} | @qcode{"eastoutside"} | @qcode{"none"} | @qcode{"north"} | @{@qcode{"northeast"}@} | @qcode{"northeastoutside"} | @qcode{"northoutside"} | @qcode{"northwest"} | @qcode{"northwestoutside"} | @qcode{"south"} | @qcode{"southeast"} | @qcode{"southeastoutside"} | @qcode{"southoutside"} | @qcode{"southwest"} | @qcode{"southwestoutside"} | @qcode{"west"} | @qcode{"westoutside"}
Control the location of the legend.


@anchor{XREFlegendposition}
@prindex legend position
@item @code{position}: four-element vector
Specify the position of the legend excluding its title.  The four elements of the vector are the coordinates of the lower left corner and width and height of the legend.  Changing this property also switches the @qcode{"location"} to @qcode{"none"}.


@anchor{XREFlegendunits}
@prindex legend units
@item @code{units}: @qcode{"centimeters"} | @qcode{"characters"} | @qcode{"inches"} | @{@qcode{"normalized"}@} | @qcode{"pixels"} | @qcode{"points"}
Units used to interpret the @qcode{"position"} property.

@end table

@anchor{XREFlegendcategoryTextAppearance}
@subsubheading Text Appearance

@table @asis

@anchor{XREFlegendfontangle}
@prindex legend fontangle
@item @code{fontangle}: @qcode{"italic"} | @{@qcode{"normal"}@}
Control whether the font is italic or normal.


@anchor{XREFlegendfontname}
@prindex legend fontname
@item @code{fontname}: string, def. @qcode{"*"}
Name of font used for text rendering.  When setting this property, the text rendering engine will search for a matching font in your system.  If none is found then text is rendered using a default sans serif font (same as the default @qcode{"*"} value).

Programming Note: On systems that don’t use FontConfig natively (all but Linux), the font cache is built when Octave is installed.  You will need to run @code{system ("fc-cache -fv")} manually after installing new fonts.


@anchor{XREFlegendfontsize}
@prindex legend fontsize
@item @code{fontsize}: scalar, def. @code{9}
Size of the font used for text rendering.  @xref{XREFlegendfontunits, , fontunits property}.  Setting @code{fontsize} also forces the @code{fontsizemode} property to be set to @qcode{"manual"}.


@anchor{XREFlegendfontunits}
@prindex legend fontunits
@item @code{fontunits}: @qcode{"centimeters"} | @qcode{"inches"} | @qcode{"normalized"} | @qcode{"pixels"} | @{@qcode{"points"}@}
Units used to interpret the @qcode{"fontsize"} property.


@anchor{XREFlegendfontweight}
@prindex legend fontweight
@item @code{fontweight}: @qcode{"bold"} | @{@qcode{"normal"}@}
Control the variant of the base font used for text rendering.


@anchor{XREFlegendstring}
@prindex legend string
@item @code{string}: string | cell array of strings
List of labels for the legend items.  For example:
@example
@group
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);
@end group
@end example


@anchor{XREFlegendtextcolor}
@prindex legend textcolor
@item @code{textcolor}: colorspec, def. @code{[0   0   0]}
Control the color of the text strings for legend items.

@end table