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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
|
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Legend Properties (GNU Octave (version 10.3.0))</title>
<meta name="description" content="Legend Properties (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Legend Properties (GNU Octave (version 10.3.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Graphics-Object-Properties.html" rel="up" title="Graphics Object Properties">
<link href="Line-Properties.html" rel="next" title="Line Properties">
<link href="Axes-Properties.html" rel="prev" title="Axes Properties">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">
</head>
<body lang="en">
<div class="subsubsection-level-extent" id="Legend-Properties">
<div class="nav-panel">
<p>
Next: <a href="Line-Properties.html" accesskey="n" rel="next">Line Properties</a>, Previous: <a href="Axes-Properties.html" accesskey="p" rel="prev">Axes Properties</a>, Up: <a href="Graphics-Object-Properties.html" accesskey="u" rel="up">Graphics Object Properties</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsubsection" id="Legend-Properties-1"><span>15.3.3.4 Legend Properties<a class="copiable-link" href="#Legend-Properties-1"> ¶</a></span></h4>
<a class="index-entry-id" id="index-Legend-Properties"></a>
<p>Properties of <code class="code">legend</code> objects (see <a class="pxref" href="Plot-Annotations.html#XREFlegend">legend</a>):
</p>
<h4 class="subsubheading" id="Categories_003a-3"><span>Categories:<a class="copiable-link" href="#Categories_003a-3"> ¶</a></span></h4>
<p><a class="ref" href="#XREFlegendcategoryCallbackExecution">Callback Execution<!-- /@w --></a> | <a class="ref" href="#XREFlegendcategoryLayout">Layout<!-- /@w --></a> | <a class="ref" href="#XREFlegendcategoryLegendAppearance">Legend Appearance<!-- /@w --></a> | <a class="ref" href="#XREFlegendcategoryObjectIdentification">Object Identification<!-- /@w --></a> | <a class="ref" href="#XREFlegendcategoryObjectPosition">Object Position<!-- /@w --></a> | <a class="ref" href="#XREFlegendcategoryTextAppearance">Text Appearance<!-- /@w --></a>
</p>
<a class="anchor" id="XREFlegendcategoryCallbackExecution"></a><h4 class="subsubheading" id="Callback-Execution-3"><span>Callback Execution<a class="copiable-link" href="#Callback-Execution-3"> ¶</a></span></h4>
<dl class="table">
<dd>
<a class="anchor" id="XREFlegenditemhitfcn"></a></dd>
<dt><a id="index-legend-itemhitfcn"></a><span><code class="code">itemhitfcn</code>: def. <code class="code">[](0x0)</code><a class="copiable-link" href="#index-legend-itemhitfcn"> ¶</a></span></dt>
<dd><p>Callback function which is executed when a legend item is clicked. See <a class="xref" href="Callbacks.html">Callbacks section<!-- /@w --></a>.
</p>
<p>The callback function must have the following prototype <code class="code">fcn (hlegend, evnt)</code>, where <code class="code">hlegend</code> is the legend object handle and <code class="code">evnt</code> is a structure with the following fields:
</p><dl class="table">
<dt><code class="code">Peer</code></dt>
<dd><p>Handle of the plot object to which the clicked item is associated.
</p></dd>
<dt><code class="code">Region</code></dt>
<dd><p>May be <code class="code">"icon"</code> or <code class="code">"label"</code> depending on which part of the item is clicked.
</p></dd>
<dt><code class="code">SelectionType</code></dt>
<dd><p>One of <code class="code">"normal"</code>, <code class="code">"extend"</code>, <code class="code">"open"</code>, or <code class="code">"alt"</code>. See <a class="xref" href="Figure-Properties.html#XREFfigureselectiontype">Figure <code class="code">"selectiontype"</code><!-- /@w --></a>.
</p></dd>
<dt><code class="code">Source</code></dt>
<dd><p>Handle of the legend object.
</p></dd>
<dt><code class="code">EventName</code></dt>
<dd><p>Name is <code class="code">"ItemHit"</code>.
</p></dd>
</dl>
</dd>
</dl>
<a class="anchor" id="XREFlegendcategoryLayout"></a><h4 class="subsubheading" id="Layout"><span>Layout<a class="copiable-link" href="#Layout"> ¶</a></span></h4>
<dl class="table">
<dd>
<a class="anchor" id="XREFlegendautoupdate"></a></dd>
<dt><a id="index-legend-autoupdate"></a><span><code class="code">autoupdate</code>: <code class="code">"off"</code> | {<code class="code">"on"</code>}<a class="copiable-link" href="#index-legend-autoupdate"> ¶</a></span></dt>
<dd><p>Control whether the number of legend items is updated automatically when objects are added to (or deleted from) the peer axes.
For example:
</p><div class="example">
<div class="group"><pre class="example-preformatted">## 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);
</pre></div></div>
<a class="anchor" id="XREFlegendnumcolumns"></a></dd>
<dt><a id="index-legend-numcolumns"></a><span><code class="code">numcolumns</code>: scalar integer, def. <code class="code">1</code><a class="copiable-link" href="#index-legend-numcolumns"> ¶</a></span></dt>
<dd><p>Control the number of columns used in the layout of the legend items. For example:
</p><div class="example">
<div class="group"><pre class="example-preformatted">figure ();
plot (rand (30));
legend ("numcolumns", 3);
</pre></div></div>
<p>Setting <code class="code">numcolumns</code> also forces the <code class="code">numcolumnsmode</code> property to be set to <code class="code">"manual"</code>.
</p>
<a class="anchor" id="XREFlegendorientation"></a></dd>
<dt><a id="index-legend-orientation"></a><span><code class="code">orientation</code>: <code class="code">"horizontal"</code> | {<code class="code">"vertical"</code>}<a class="copiable-link" href="#index-legend-orientation"> ¶</a></span></dt>
<dd><p>Control whether the legend items are arranged vertically (column-wise) or horizontally (row-wise).
</p>
</dd>
</dl>
<a class="anchor" id="XREFlegendcategoryLegendAppearance"></a><h4 class="subsubheading" id="Legend-Appearance"><span>Legend Appearance<a class="copiable-link" href="#Legend-Appearance"> ¶</a></span></h4>
<dl class="table">
<dd>
<a class="anchor" id="XREFlegendbox"></a></dd>
<dt><a id="index-legend-box"></a><span><code class="code">box</code>: <code class="code">"off"</code> | {<code class="code">"on"</code>}<a class="copiable-link" href="#index-legend-box"> ¶</a></span></dt>
<dd><p>Control whether the legend has a surrounding box.
</p>
<a class="anchor" id="XREFlegendcolor"></a></dd>
<dt><a id="index-legend-color"></a><span><code class="code">color</code>: colorspec, def. <code class="code">[1 1 1]</code><a class="copiable-link" href="#index-legend-color"> ¶</a></span></dt>
<dd><p>Color of the legend background. See <a class="xref" href="Colors.html">colorspec</a>.
</p>
<a class="anchor" id="XREFlegendedgecolor"></a></dd>
<dt><a id="index-legend-edgecolor"></a><span><code class="code">edgecolor</code>: colorspec, def. <code class="code">[0.1500 0.1500 0.1500]</code><a class="copiable-link" href="#index-legend-edgecolor"> ¶</a></span></dt>
<dd><p>Control the color of the legend outline.
</p>
</dd>
</dl>
<a class="anchor" id="XREFlegendcategoryObjectIdentification"></a><h4 class="subsubheading" id="Object-Identification-3"><span>Object Identification<a class="copiable-link" href="#Object-Identification-3"> ¶</a></span></h4>
<dl class="table">
<dd>
<a class="anchor" id="XREFlegendtitle"></a></dd>
<dt><a id="index-legend-title"></a><span><code class="code">title</code>: graphics handle<a class="copiable-link" href="#index-legend-title"> ¶</a></span></dt>
<dd><p>Graphics handle of the title text object.
</p>
</dd>
</dl>
<a class="anchor" id="XREFlegendcategoryObjectPosition"></a><h4 class="subsubheading" id="Object-Position-2"><span>Object Position<a class="copiable-link" href="#Object-Position-2"> ¶</a></span></h4>
<dl class="table">
<dd>
<a class="anchor" id="XREFlegendlocation"></a></dd>
<dt><a id="index-legend-location"></a><span><code class="code">location</code>: <code class="code">"best"</code> | <code class="code">"bestoutside"</code> | <code class="code">"east"</code> | <code class="code">"eastoutside"</code> | <code class="code">"none"</code> | <code class="code">"north"</code> | {<code class="code">"northeast"</code>} | <code class="code">"northeastoutside"</code> | <code class="code">"northoutside"</code> | <code class="code">"northwest"</code> | <code class="code">"northwestoutside"</code> | <code class="code">"south"</code> | <code class="code">"southeast"</code> | <code class="code">"southeastoutside"</code> | <code class="code">"southoutside"</code> | <code class="code">"southwest"</code> | <code class="code">"southwestoutside"</code> | <code class="code">"west"</code> | <code class="code">"westoutside"</code><a class="copiable-link" href="#index-legend-location"> ¶</a></span></dt>
<dd><p>Control the location of the legend.
</p>
<a class="anchor" id="XREFlegendposition"></a></dd>
<dt><a id="index-legend-position"></a><span><code class="code">position</code>: four-element vector<a class="copiable-link" href="#index-legend-position"> ¶</a></span></dt>
<dd><p>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 <code class="code">"location"</code> to <code class="code">"none"</code>.
</p>
<a class="anchor" id="XREFlegendunits"></a></dd>
<dt><a id="index-legend-units"></a><span><code class="code">units</code>: <code class="code">"centimeters"</code> | <code class="code">"characters"</code> | <code class="code">"inches"</code> | {<code class="code">"normalized"</code>} | <code class="code">"pixels"</code> | <code class="code">"points"</code><a class="copiable-link" href="#index-legend-units"> ¶</a></span></dt>
<dd><p>Units used to interpret the <code class="code">"position"</code> property.
</p>
</dd>
</dl>
<a class="anchor" id="XREFlegendcategoryTextAppearance"></a><h4 class="subsubheading" id="Text-Appearance-1"><span>Text Appearance<a class="copiable-link" href="#Text-Appearance-1"> ¶</a></span></h4>
<dl class="table">
<dd>
<a class="anchor" id="XREFlegendfontangle"></a></dd>
<dt><a id="index-legend-fontangle"></a><span><code class="code">fontangle</code>: <code class="code">"italic"</code> | {<code class="code">"normal"</code>}<a class="copiable-link" href="#index-legend-fontangle"> ¶</a></span></dt>
<dd><p>Control whether the font is italic or normal.
</p>
<a class="anchor" id="XREFlegendfontname"></a></dd>
<dt><a id="index-legend-fontname"></a><span><code class="code">fontname</code>: string, def. <code class="code">"*"</code><a class="copiable-link" href="#index-legend-fontname"> ¶</a></span></dt>
<dd><p>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 <code class="code">"*"</code> value).
</p>
<p>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 class="code">system ("fc-cache -fv")</code> manually after installing new fonts.
</p>
<a class="anchor" id="XREFlegendfontsize"></a></dd>
<dt><a id="index-legend-fontsize"></a><span><code class="code">fontsize</code>: scalar, def. <code class="code">9</code><a class="copiable-link" href="#index-legend-fontsize"> ¶</a></span></dt>
<dd><p>Size of the font used for text rendering. See <a class="xref" href="#XREFlegendfontunits">fontunits property</a>. Setting <code class="code">fontsize</code> also forces the <code class="code">fontsizemode</code> property to be set to <code class="code">"manual"</code>.
</p>
<a class="anchor" id="XREFlegendfontunits"></a></dd>
<dt><a id="index-legend-fontunits"></a><span><code class="code">fontunits</code>: <code class="code">"centimeters"</code> | <code class="code">"inches"</code> | <code class="code">"normalized"</code> | <code class="code">"pixels"</code> | {<code class="code">"points"</code>}<a class="copiable-link" href="#index-legend-fontunits"> ¶</a></span></dt>
<dd><p>Units used to interpret the <code class="code">"fontsize"</code> property.
</p>
<a class="anchor" id="XREFlegendfontweight"></a></dd>
<dt><a id="index-legend-fontweight"></a><span><code class="code">fontweight</code>: <code class="code">"bold"</code> | {<code class="code">"normal"</code>}<a class="copiable-link" href="#index-legend-fontweight"> ¶</a></span></dt>
<dd><p>Control the variant of the base font used for text rendering.
</p>
<a class="anchor" id="XREFlegendstring"></a></dd>
<dt><a id="index-legend-string"></a><span><code class="code">string</code>: string | cell array of strings<a class="copiable-link" href="#index-legend-string"> ¶</a></span></dt>
<dd><p>List of labels for the legend items. For example:
</p><div class="example">
<div class="group"><pre class="example-preformatted">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);
</pre></div></div>
<a class="anchor" id="XREFlegendtextcolor"></a></dd>
<dt><a id="index-legend-textcolor"></a><span><code class="code">textcolor</code>: colorspec, def. <code class="code">[0 0 0]</code><a class="copiable-link" href="#index-legend-textcolor"> ¶</a></span></dt>
<dd><p>Control the color of the text strings for legend items.
</p>
</dd>
</dl>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Line-Properties.html">Line Properties</a>, Previous: <a href="Axes-Properties.html">Axes Properties</a>, Up: <a href="Graphics-Object-Properties.html">Graphics Object Properties</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|