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>5.36. Example - Legend Positioning</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="examples.html" title="Chapter 5. PHPlot Examples" /><link rel="prev" href="ex-legendshape.html" title="5.35. Example - Legend with Shape Markers" /><link rel="next" href="ex-ytickanchor.html" title="5.37. Example - Setting a Y Tick Anchor" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">5.36. Example - Legend Positioning</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ex-legendshape.html">Prev</a> </td><th width="60%" align="center">Chapter 5. PHPlot Examples</th><td width="20%" align="right"> <a accesskey="n" href="ex-ytickanchor.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="ex-legendpos"></a>5.36. Example - Legend Positioning</h2></div></div></div><p>
|
|
|
3 |
Here are some examples showing the usage of <a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a>
|
|
|
4 |
to position the legend on the plot. The first two arguments ($x, $y)
|
|
|
5 |
indicate a point on the legend box, relative to the legend box size, with
|
|
|
6 |
(0,0) being the upper left corner, and (1,1) being the lower right corner.
|
|
|
7 |
The third argument $relative_to indicates the positioning mode: image, plot,
|
|
|
8 |
world, or title. The next two arguments ($x_base, $y_base), along with the
|
|
|
9 |
positioning mode, indicate where to place the legend point given in the
|
|
|
10 |
first two arguments. The last two optional arguments ($x_offset, $y_offset)
|
|
|
11 |
are an additional pixel offset.
|
|
|
12 |
</p><div class="example"><a id="example-legendpos"></a><p class="title"><strong>Example 5.36. Legend Positioning</strong></p><div class="example-contents"><p>
|
|
|
13 |
Case 1. Place upper left corner of legend at offset (5,5) from upper left corner of image:
|
|
|
14 |
</p><pre class="programlisting">$plot->SetLegendPosition(0, 0, 'image', 0, 0, 5, 5);
|
|
|
15 |
</pre><p>
|
|
|
16 |
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos1.png" alt="Legend Position Case 1" /></div></div><p>
|
|
|
17 |
</p><p>
|
|
|
18 |
Case 2. Place bottom left corner of legend at offset (7,-7) from bottom
|
|
|
19 |
left corner of image:
|
|
|
20 |
</p><pre class="programlisting">$plot->SetLegendPosition(0, 1, 'image', 0, 1, 7, -7);
|
|
|
21 |
</pre><p>
|
|
|
22 |
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos2.png" alt="Legend Position Case 2" /></div></div><p>
|
|
|
23 |
</p><p>
|
|
|
24 |
Case 3. Place top right corner of legend at top center of plot area:
|
|
|
25 |
</p><pre class="programlisting">$plot->SetLegendPosition(1, 0, 'plot', 0.5, 0);
|
|
|
26 |
</pre><p>
|
|
|
27 |
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos3.png" alt="Legend Position Case 3" /></div></div><p>
|
|
|
28 |
</p><p>
|
|
|
29 |
Case 4. Center the legend in the upper half of the plot area:
|
|
|
30 |
</p><pre class="programlisting">$plot->SetLegendPosition(0.5, 0.5, 'plot', 0.5, 0.25);
|
|
|
31 |
</pre><p>
|
|
|
32 |
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos4.png" alt="Legend Position Case 4" /></div></div><p>
|
|
|
33 |
</p><p>
|
|
|
34 |
Case 5. Place center of legend at world coordinates (2,60):
|
|
|
35 |
</p><pre class="programlisting">$plot->SetLegendPosition(0.5, 0.5, 'world', 2, 60);
|
|
|
36 |
</pre><p>
|
|
|
37 |
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos5.png" alt="Legend Position Case 5" /></div></div><p>
|
|
|
38 |
</p><p>
|
|
|
39 |
Case 6. Place top right corner of legend at offset (-5,5) from world
|
|
|
40 |
coordinates (4,0):
|
|
|
41 |
</p><pre class="programlisting">$plot->SetLegendPosition(1, 0, 'world', 4, 0, -5, 5);
|
|
|
42 |
</pre><p>
|
|
|
43 |
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos6.png" alt="Legend Position Case 6" /></div></div><p>
|
|
|
44 |
</p><p>
|
|
|
45 |
Case 7. Center the top of the legend below the bottom of the title:
|
|
|
46 |
</p><pre class="programlisting">$plot->SetLegendPosition(0.5, 0, 'title', 0.5, 1);
|
|
|
47 |
</pre><p>
|
|
|
48 |
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos7.png" alt="Legend Position Case 7" /></div></div><p>
|
|
|
49 |
</p></div></div><br class="example-break" /></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ex-legendshape.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="examples.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ex-ytickanchor.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">5.35. Example - Legend with Shape Markers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 5.37. Example - Setting a Y Tick Anchor</td></tr></table></div></body></html>
|