98 |
- |
1 |
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
|
|
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>SetLegendPosition</title><link rel="stylesheet" type="text/css" href="phplotdoc.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="PHPlot Reference Manual" /><link rel="up" href="reference.html" title="PHPlot Function Reference" /><link rel="prev" href="SetLegendPixels.html" title="SetLegendPixels" /><link rel="next" href="SetLegendReverse.html" title="SetLegendReverse" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">SetLegendPosition</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="SetLegendPixels.html">Prev</a> </td><th width="60%" align="center">PHPlot Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="SetLegendReverse.html">Next</a></td></tr></table><hr /></div><div class="refentry"><a id="SetLegendPosition"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">SetLegendPosition</span></h2><p>SetLegendPosition — Position the legend</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">$plot->SetLegendPosition(<em class="parameter"><code>$x</code></em>, <em class="parameter"><code>$y</code></em>, <em class="parameter"><code>$relative_to</code></em>, <em class="parameter"><code>$x_base</code></em>, <em class="parameter"><code>$y_base</code></em>,
|
|
|
3 |
[<span class="optional"><em class="parameter"><code>$x_offset</code></em></span>], [<span class="optional"><em class="parameter"><code>$y_offset</code></em></span>])</pre></div><div class="refsect1"><a id="idp1378263996"></a><h2>Description</h2><p>
|
|
|
4 |
<code class="function">SetLegendPosition</code> lets you position the legend on the
|
|
|
5 |
image, using <a class="link" href="concepts.html#def-relativecoor">relative coordinates</a>,
|
|
|
6 |
world coordinates, or device (pixel) coordinates.
|
|
|
7 |
</p></div><div class="refsect1"><a id="idp1378265580"></a><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>$x</code></em>, </span><span class="term"><em class="replaceable"><code>$y</code></em></span></dt><dd><p>
|
|
|
8 |
Relative coordinates of a point on the legend box to use as a reference.
|
|
|
9 |
The coordinates are relative to the size of the legend box, with the upper
|
|
|
10 |
left corner as (0.0, 0.0) and the lower right corner as (1.0, 1.0).
|
|
|
11 |
</p></dd><dt><span class="term"><em class="replaceable"><code>$relative_to</code></em></span></dt><dd><p>
|
|
|
12 |
A string indicating how the next two parameters ($x_base, $y_base) are
|
|
|
13 |
interpreted. Accepted values are: image, plot, world, or title. See the
|
|
|
14 |
description of the next parameters for details.
|
|
|
15 |
</p></dd><dt><span class="term"><em class="replaceable"><code>$x_base</code></em>, </span><span class="term"><em class="replaceable"><code>$y_base</code></em></span></dt><dd><p>
|
|
|
16 |
Reference point for positioning the legend. The interpretation depends on
|
|
|
17 |
the previous parameter $relative_to as follows.
|
|
|
18 |
</p><div class="informaltable"><table summary="Legend position relative to choices" border="1"><colgroup><col class="c1" /><col class="c2" /></colgroup><thead><tr><th>$relative_to</th><th>$x_base, $y_base</th></tr></thead><tbody><tr><td>image</td><td>
|
|
|
19 |
Relative coordinates of a point on the image.
|
|
|
20 |
The point on the legend box indicated by ($x, $y) is placed at this point.
|
|
|
21 |
These coordinates are relative to the size of the image, with (0.0, 0.0)
|
|
|
22 |
being the upper left corner, and (1.0, 1.0) being the lower right corner.
|
|
|
23 |
</td></tr><tr><td>plot</td><td>
|
|
|
24 |
Relative coordinates of a point on the plot area. (The plot area is
|
|
|
25 |
generally the area enclosed by the X and Y axis lines.)
|
|
|
26 |
The point on the legend box indicated by ($x, $y) is placed at this point.
|
|
|
27 |
These coordinates are relative to the size of the plot area, with (0.0, 0.0)
|
|
|
28 |
being the upper left corner, and (1.0, 1.0) being the lower right corner.
|
|
|
29 |
</td></tr><tr><td>title</td><td>
|
|
|
30 |
Relative coordinates of a point in the main plot title.
|
|
|
31 |
The point on the legend box indicated by ($x, $y) is placed at this point.
|
|
|
32 |
These coordinates are relative to a bounding box which encloses the main
|
|
|
33 |
plot title, with (0.0, 0.0) being the upper left corner of the title,
|
|
|
34 |
and (1.0, 1.0) being the lower right corner.
|
|
|
35 |
</td></tr><tr><td>world</td><td>
|
|
|
36 |
World coordinates
|
|
|
37 |
</td></tr></tbody></table></div><p>
|
|
|
38 |
</p></dd><dt><span class="term"><em class="replaceable"><code>$x_offset</code></em>, </span><span class="term"><em class="replaceable"><code>$y_offset</code></em></span></dt><dd><p>
|
|
|
39 |
Optional arguments specifying an additional offset for the legend, in device
|
|
|
40 |
(pixel) coordinates. After the legend position has been calculated using
|
|
|
41 |
the preceding arguments, this offset is added to the position. It can be
|
|
|
42 |
used to move the legend a little bit away from the edge of the image or
|
|
|
43 |
plot, for example. If not specified, no offset is applied.
|
|
|
44 |
</p></dd></dl></div></div><div class="refsect1"><a id="idp1378277564"></a><h2>Notes</h2><p>
|
|
|
45 |
For examples of using <code class="function">SetLegendPosition</code>, see
|
|
|
46 |
<a class="xref" href="ex-legendpos.html" title="5.36. Example - Legend Positioning">Section 5.36, “Example - Legend Positioning”</a>.
|
|
|
47 |
</p><p>
|
|
|
48 |
By default, PHPlot will position the legend in the upper right corner of
|
|
|
49 |
the plot area, with a small offset. This is equivalent to:
|
|
|
50 |
</p><pre class="programlisting">$plot->SetLegendPosition(1, 0, 'plot', 1, 0, -5, 5);
|
|
|
51 |
</pre><p>
|
|
|
52 |
The default behavior can be restored by using NULL for the $x and $y arguments
|
|
|
53 |
(or the $x_offset and $y_offset arguments)
|
|
|
54 |
in <code class="function">SetLegendPosition</code>.
|
|
|
55 |
That is, using NULL for any of those arguments undoes any previous call to
|
|
|
56 |
SetLegendPosition, SetLegendPixels, and SetLegendWorld.
|
|
|
57 |
</p><p>
|
|
|
58 |
See <a class="xref" href="SetLegendPixels.html" title="SetLegendPixels"><span class="refentrytitle">SetLegendPixels</span></a> and <a class="xref" href="SetLegendWorld.html" title="SetLegendWorld"><span class="refentrytitle">SetLegendWorld</span></a>
|
|
|
59 |
for simpler forms of legend positioning.
|
|
|
60 |
</p><p>
|
|
|
61 |
<code class="literal">SetLegendWorld($x, $y)</code> is equivalent to
|
|
|
62 |
<code class="literal">SetLegendPosition(0, 0, 'world', $x, $y)</code>.
|
|
|
63 |
</p><p>
|
|
|
64 |
<code class="literal">SetLegendPixels($x, $y)</code> is equivalent to
|
|
|
65 |
<code class="literal">SetLegendPosition(0, 0, 'image', 0, 0, $x, $y)</code>.
|
|
|
66 |
</p><p>
|
|
|
67 |
The value of each of X and Y used in relative coordinates are usually in the
|
|
|
68 |
range (0.0 <= x, y <= 1.0), but this is not required by PHPlot.
|
|
|
69 |
For the legend box reference point ($x, $y) or when using 'title' or
|
|
|
70 |
'plot' mode ($base_x, $base_y), a value outside this range may be used to
|
|
|
71 |
refer to a point outside the object. For example, using (-1, -1) for ($x, $y)
|
|
|
72 |
indicates a point above and to the left of the upper left corner of the
|
|
|
73 |
legend box at a distance equal to the width and height of the legend box.
|
|
|
74 |
Relative coordinates outside this range for 'image' mode ($base_x, $base_y)
|
|
|
75 |
will be outside the image and not visible.
|
|
|
76 |
</p><p>
|
|
|
77 |
Positioning relative to 'world' will not work with pie charts, because they
|
|
|
78 |
have no valid world coordinates.
|
|
|
79 |
</p></div><div class="refsect1"><a id="idp1378285148"></a><h2>History</h2><p>
|
|
|
80 |
This function was added in PHPlot-5.4.0, and
|
|
|
81 |
<a class="xref" href="SetLegendPixels.html" title="SetLegendPixels"><span class="refentrytitle">SetLegendPixels</span></a> and <a class="xref" href="SetLegendWorld.html" title="SetLegendWorld"><span class="refentrytitle">SetLegendWorld</span></a>
|
|
|
82 |
were changed to be simple wrappers that call
|
|
|
83 |
<code class="function">SetLegendPosition</code>.
|
|
|
84 |
No other legend positioning methods were available in earlier releases.
|
|
|
85 |
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="SetLegendPixels.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="SetLegendReverse.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">SetLegendPixels </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> SetLegendReverse</td></tr></table></div></body></html>
|