Blame | Last modification | View Log | RSS feed
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!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>
Here are some examples showing the usage of <a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a>
to position the legend on the plot. The first two arguments ($x, $y)
indicate a point on the legend box, relative to the legend box size, with
(0,0) being the upper left corner, and (1,1) being the lower right corner.
The third argument $relative_to indicates the positioning mode: image, plot,
world, or title. The next two arguments ($x_base, $y_base), along with the
positioning mode, indicate where to place the legend point given in the
first two arguments. The last two optional arguments ($x_offset, $y_offset)
are an additional pixel offset.
</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>
Case 1. Place upper left corner of legend at offset (5,5) from upper left corner of image:
</p><pre class="programlisting">$plot->SetLegendPosition(0, 0, 'image', 0, 0, 5, 5);
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos1.png" alt="Legend Position Case 1" /></div></div><p>
</p><p>
Case 2. Place bottom left corner of legend at offset (7,-7) from bottom
left corner of image:
</p><pre class="programlisting">$plot->SetLegendPosition(0, 1, 'image', 0, 1, 7, -7);
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos2.png" alt="Legend Position Case 2" /></div></div><p>
</p><p>
Case 3. Place top right corner of legend at top center of plot area:
</p><pre class="programlisting">$plot->SetLegendPosition(1, 0, 'plot', 0.5, 0);
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos3.png" alt="Legend Position Case 3" /></div></div><p>
</p><p>
Case 4. Center the legend in the upper half of the plot area:
</p><pre class="programlisting">$plot->SetLegendPosition(0.5, 0.5, 'plot', 0.5, 0.25);
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos4.png" alt="Legend Position Case 4" /></div></div><p>
</p><p>
Case 5. Place center of legend at world coordinates (2,60):
</p><pre class="programlisting">$plot->SetLegendPosition(0.5, 0.5, 'world', 2, 60);
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos5.png" alt="Legend Position Case 5" /></div></div><p>
</p><p>
Case 6. Place top right corner of legend at offset (-5,5) from world
coordinates (4,0):
</p><pre class="programlisting">$plot->SetLegendPosition(1, 0, 'world', 4, 0, -5, 5);
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos6.png" alt="Legend Position Case 6" /></div></div><p>
</p><p>
Case 7. Center the top of the legend below the bottom of the title:
</p><pre class="programlisting">$plot->SetLegendPosition(0.5, 0, 'title', 0.5, 1);
</pre><p>
</p><div class="informalfigure"><div class="mediaobject"><img src="images/legendpos7.png" alt="Legend Position Case 7" /></div></div><p>
</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>