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>4.8. Multiple Plots Per Image</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="advanced.html" title="Chapter 4. PHPlot Advanced Topics" /><link rel="prev" href="adv-tuning.html" title="4.7. Tuning Parameters" /><link rel="next" href="adv-streaming.html" title="4.9. Streaming Plots" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">4.8. Multiple Plots Per Image</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="adv-tuning.html">Prev</a> </td><th width="60%" align="center">Chapter 4. PHPlot Advanced Topics</th><td width="20%" align="right"> <a accesskey="n" href="adv-streaming.html">Next</a></td></tr></table><hr /></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="adv-multiplot"></a>4.8. Multiple Plots Per Image</h2></div></div></div><div class="abstract"><p class="title"><strong></strong></p><p>
|
|
|
3 |
This section contains information about producing more than one plot on an
|
|
|
4 |
image.
|
|
|
5 |
</p></div><p>
|
|
|
6 |
Using PHPlot, you can produce more than one plot on a single image. These can
|
|
|
7 |
be <span class="emphasis"><em>tiled plots</em></span> - separate plots manually positioned within
|
|
|
8 |
the image, or <span class="emphasis"><em>overlay plots</em></span>.
|
|
|
9 |
Tiled plots are used when you want to display more than one plot on a single
|
|
|
10 |
image, for example side-by-side.
|
|
|
11 |
Overlay plots are used when you want to show more than one type or range
|
|
|
12 |
of data representation on a single plot. For example, an overlay plot could
|
|
|
13 |
be used to show two data sets with different Y scales, or to overlay a bar
|
|
|
14 |
chart with a line plot.
|
|
|
15 |
You can also combine tiled and overlay plots in a single image.
|
|
|
16 |
</p><p>
|
|
|
17 |
An example of two tiled plots on an image can be found in
|
|
|
18 |
<a class="xref" href="ex-twoplot1.html" title="5.18. Example - Two Plots on One Image">Section 5.18, “Example - Two Plots on One Image”</a>.
|
|
|
19 |
An example of an overlay plot can be found in
|
|
|
20 |
<a class="xref" href="ex-outbreak.html" title="5.34. Example - Overlaying Plots">Section 5.34, “Example - Overlaying Plots”</a>
|
|
|
21 |
</p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="adv-multiplot-overview"></a>4.8.1. Overview of Multiple Plots</h3></div></div></div><p>
|
|
|
22 |
When producing multiple plots on an image, a single PHPlot object is used.
|
|
|
23 |
The overall steps to be followed are:
|
|
|
24 |
</p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
|
|
|
25 |
Create a <code class="function">PHPlot</code> or <code class="function">PHPlot_truecolor</code>
|
|
|
26 |
object (referred to here as <code class="literal">$plot</code>).
|
|
|
27 |
</p></li><li class="listitem"><p>
|
|
|
28 |
Use <code class="literal">$plot->SetPrintImage(False)</code> to disable automatic
|
|
|
29 |
output of the image after a plot is created.
|
|
|
30 |
</p></li><li class="listitem"><p>
|
|
|
31 |
Prepare the first plot, including setting the data array, plot type, and any
|
|
|
32 |
other applicable settings.
|
|
|
33 |
</p></li><li class="listitem"><p>
|
|
|
34 |
Use <code class="literal">$plot->DrawGraph()</code> when complete.
|
|
|
35 |
This creates the plot, but does not produce any output.
|
|
|
36 |
</p></li><li class="listitem"><p>
|
|
|
37 |
Repeat the previous two steps to prepare each additional plot, completing
|
|
|
38 |
it with <code class="literal">$plot->DrawGraph()</code>.
|
|
|
39 |
</p></li><li class="listitem"><p>
|
|
|
40 |
When all the plots are complete, use <code class="literal">$plot->PrintImage()</code> to
|
|
|
41 |
output the completed image.
|
|
|
42 |
</p></li></ol></div><p>
|
|
|
43 |
</p><p>
|
|
|
44 |
The sections which follow contain additional information you will need
|
|
|
45 |
to produce multiple plots on a single image.
|
|
|
46 |
</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="adv-multiplot-settings"></a>4.8.2. Plot Settings with Multiple Plots</h3></div></div></div><p>
|
|
|
47 |
In general, PHPlot applies settings made for one plot as defaults for the
|
|
|
48 |
next plot, when using the same PHPlot class instance.
|
|
|
49 |
There are some special cases, however, which are discussed in the
|
|
|
50 |
sections below.
|
|
|
51 |
</p><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-global"></a>4.8.2.1. Global Settings</h4></div></div></div><p>
|
|
|
52 |
Certain plot elements apply to the image as a whole, not to individual plots.
|
|
|
53 |
PHPlot will draw these at most once per image. (That is, the element will be
|
|
|
54 |
drawn only the first time <code class="literal">DrawGraph()</code> is called after the
|
|
|
55 |
element has been set up.)
|
|
|
56 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
|
|
57 |
Main title (<a class="xref" href="SetTitle.html" title="SetTitle"><span class="refentrytitle">SetTitle</span></a>)
|
|
|
58 |
</p></li><li class="listitem"><p>
|
|
|
59 |
Image background color (<a class="xref" href="SetBackgroundColor.html" title="SetBackgroundColor"><span class="refentrytitle">SetBackgroundColor</span></a>)
|
|
|
60 |
or image background file (<a class="xref" href="SetBgImage.html" title="SetBgImage"><span class="refentrytitle">SetBgImage</span></a>)
|
|
|
61 |
</p></li><li class="listitem"><p>
|
|
|
62 |
Image border (<a class="xref" href="SetImageBorderColor.html" title="SetImageBorderColor"><span class="refentrytitle">SetImageBorderColor</span></a> and
|
|
|
63 |
<a class="xref" href="SetImageBorderType.html" title="SetImageBorderType"><span class="refentrytitle">SetImageBorderType</span></a>)
|
|
|
64 |
</p></li></ul></div><p>
|
|
|
65 |
For example, the first plot on an image that has a main title will result in
|
|
|
66 |
the main title being drawn. If any subsequent plot (using the same PHPlot
|
|
|
67 |
instance) also sets a main title, that will be ignored.
|
|
|
68 |
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-datascale"></a>4.8.2.2. Data Scaling</h4></div></div></div><p>
|
|
|
69 |
Whether you use <a class="xref" href="SetPlotAreaWorld.html" title="SetPlotAreaWorld"><span class="refentrytitle">SetPlotAreaWorld</span></a> to set the plot area
|
|
|
70 |
data range, or you let PHPlot calculate the plot area data range,
|
|
|
71 |
that range applies to all subsequent plots unless overridden.
|
|
|
72 |
Even if you set a new data array, the calculated or pre-set data range from
|
|
|
73 |
the previous plot applies. Without being told otherwise, PHPlot will not
|
|
|
74 |
re-examine the data array to recalculate the data range.
|
|
|
75 |
This allows you to re-use an automatically calculated data range, if you want.
|
|
|
76 |
</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
|
|
|
77 |
Nothing related to world coordinates and data scaling applies to pie charts,
|
|
|
78 |
which have do not use world coordinates.
|
|
|
79 |
</p></div><p>
|
|
|
80 |
</p><p>
|
|
|
81 |
If instead you want PHPlot to automatically calculate the data range for
|
|
|
82 |
additional plots, call <code class="literal">SetPlotAreaWorld()</code> (with no
|
|
|
83 |
arguments), or <code class="literal">SetPlotAreaWorld(NULL, NULL, NULL, NULL)</code>.
|
|
|
84 |
Either of these forms causes PHPlot to forget about a specified or
|
|
|
85 |
calculated data range, and it will compute a new range.
|
|
|
86 |
</p><p>
|
|
|
87 |
Of course, you can also use <a class="xref" href="SetPlotAreaWorld.html" title="SetPlotAreaWorld"><span class="refentrytitle">SetPlotAreaWorld</span></a> with
|
|
|
88 |
parameter values, to manually set all or part of the data range for each plot.
|
|
|
89 |
Any parameters you do not set (or specify as NULL) will be calculated based
|
|
|
90 |
on the data array for the current plot.
|
|
|
91 |
That is, PHPlot will forget about the previous data range once you call
|
|
|
92 |
<a class="xref" href="SetPlotAreaWorld.html" title="SetPlotAreaWorld"><span class="refentrytitle">SetPlotAreaWorld</span></a>, regardless of how many non-NULL parameters
|
|
|
93 |
you use.
|
|
|
94 |
</p><p>
|
|
|
95 |
When overlaying plots, you will often want all the plots to use the same
|
|
|
96 |
data scale, so the values can be read off of the axis. Another option is to
|
|
|
97 |
have two separate Y scales, with one represented on the left side and one
|
|
|
98 |
on the right side. (See <a class="xref" href="ex-outbreak.html" title="5.34. Example - Overlaying Plots">Section 5.34, “Example - Overlaying Plots”</a> for an example of
|
|
|
99 |
overlaying plots with two different Y scales.)
|
|
|
100 |
In some cases it may make sense to overlay plots with different scales and
|
|
|
101 |
no separate axis, for example when using data value labels, or when the
|
|
|
102 |
important information is the trend or shape shown by the graph rather than
|
|
|
103 |
the actual values.
|
|
|
104 |
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-plotarea"></a>4.8.2.3. Plot Area</h4></div></div></div><p>
|
|
|
105 |
You can specify a plot area (window) with <a class="xref" href="SetPlotAreaPixels.html" title="SetPlotAreaPixels"><span class="refentrytitle">SetPlotAreaPixels</span></a>
|
|
|
106 |
or <a class="xref" href="SetMarginsPixels.html" title="SetMarginsPixels"><span class="refentrytitle">SetMarginsPixels</span></a>, or you can let PHPlot calculate a
|
|
|
107 |
plot area.
|
|
|
108 |
Whether you set the plot area yourself, or you let PHPlot calculate
|
|
|
109 |
it, those settings apply to all subsequent plots unless overridden.
|
|
|
110 |
</p><p>
|
|
|
111 |
This means that if you are doing side-by-side (tiled) plots on an image,
|
|
|
112 |
you must use <a class="xref" href="SetPlotAreaPixels.html" title="SetPlotAreaPixels"><span class="refentrytitle">SetPlotAreaPixels</span></a> or
|
|
|
113 |
<a class="xref" href="SetMarginsPixels.html" title="SetMarginsPixels"><span class="refentrytitle">SetMarginsPixels</span></a> with each plot, to set
|
|
|
114 |
the area of the image to be used for that plot.
|
|
|
115 |
Remember that the plot area does not include the axis labels, tick marks,
|
|
|
116 |
or titles, so you must leave enough room between and around plots for these.
|
|
|
117 |
</p><p>
|
|
|
118 |
If you are doing overlay plots, you can let PHPlot calculate the plot area
|
|
|
119 |
for the first plot, or you can specify the area with
|
|
|
120 |
<a class="xref" href="SetPlotAreaPixels.html" title="SetPlotAreaPixels"><span class="refentrytitle">SetPlotAreaPixels</span></a> or <a class="xref" href="SetMarginsPixels.html" title="SetMarginsPixels"><span class="refentrytitle">SetMarginsPixels</span></a>.
|
|
|
121 |
You need not use these for subsequent plots; PHPlot will continue to use the
|
|
|
122 |
same window, overlaying the additional plots.
|
|
|
123 |
</p><p>
|
|
|
124 |
However, if you allow PHPlot to calculate the plot area, it will only use
|
|
|
125 |
information in the first plot to determine the margins.
|
|
|
126 |
This will not work well if subsequent plots require more margin space.
|
|
|
127 |
For example, if the first plot has a Y axis title and tick labels only on the
|
|
|
128 |
left side, and the second overlay plot has a Y axis title and tick labels
|
|
|
129 |
on the right side, automatic plot area calculation will only leave enough
|
|
|
130 |
margin space on the left side. As a result, the right side Y axis title and
|
|
|
131 |
tick labels may fall off the image edge. To avoid this, use either
|
|
|
132 |
<a class="xref" href="SetPlotAreaPixels.html" title="SetPlotAreaPixels"><span class="refentrytitle">SetPlotAreaPixels</span></a> or <a class="xref" href="SetMarginsPixels.html" title="SetMarginsPixels"><span class="refentrytitle">SetMarginsPixels</span></a>
|
|
|
133 |
to specify large enough margins.
|
|
|
134 |
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-ticks"></a>4.8.2.4. Tick Increment</h4></div></div></div><p>
|
|
|
135 |
Tick increments are recalculated for each plot, based on the data range, unless
|
|
|
136 |
set with <a class="xref" href="SetXTickIncrement.html" title="SetXTickIncrement"><span class="refentrytitle">SetXTickIncrement</span></a>
|
|
|
137 |
or <a class="xref" href="SetYTickIncrement.html" title="SetYTickIncrement"><span class="refentrytitle">SetYTickIncrement</span></a>.
|
|
|
138 |
'Data range' here refers to that set with <a class="xref" href="SetPlotAreaWorld.html" title="SetPlotAreaWorld"><span class="refentrytitle">SetPlotAreaWorld</span></a>,
|
|
|
139 |
or automatically calculated.
|
|
|
140 |
This differs from the way PHPlot handles the data range, which is not
|
|
|
141 |
recalculated by default after the first plot.
|
|
|
142 |
</p><p>
|
|
|
143 |
For overlay plots, if you want to use the same tick increments,
|
|
|
144 |
you should either set the desired tick increment (doing this for the first
|
|
|
145 |
plot is sufficient), or make sure the data ranges match.
|
|
|
146 |
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-grid"></a>4.8.2.5. Grid Lines</h4></div></div></div><p>
|
|
|
147 |
PHPlot defaults to drawing the dependent variable grid (usually Y), and the
|
|
|
148 |
grid lines will be drawn at tick positions.
|
|
|
149 |
As stated above, the tick positions by default will be recalculated for
|
|
|
150 |
each plot, using the calculated or explicitly set data range.
|
|
|
151 |
</p><p>
|
|
|
152 |
For overlay plots, you generally do not want to have more than one set of
|
|
|
153 |
grid lines in each of X and Y, or the results will be confusing. Even if
|
|
|
154 |
your plot overlays have the same tick increments, avoid having the grid
|
|
|
155 |
lines drawn more than once. Otherwise, the grid lines for the second plot
|
|
|
156 |
will overlay the plotted data from the first plot.
|
|
|
157 |
You can turn off the grid lines with <code class="literal">SetDrawXGrid(False)</code>
|
|
|
158 |
and <code class="literal">SetDrawYGrid(False)</code>.
|
|
|
159 |
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-legend"></a>4.8.2.6. Legend Positioning</h4></div></div></div><p>
|
|
|
160 |
Legend position with multiple plots works differently depending on whether
|
|
|
161 |
the position is defaulted or set, and if set what method was used.
|
|
|
162 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
|
|
163 |
If the legend position is defaulted, a legend will be drawn at the upper
|
|
|
164 |
right corner of each plot.
|
|
|
165 |
The same legend will be drawn in each position, unless the contents are
|
|
|
166 |
changed with <a class="xref" href="SetLegend.html" title="SetLegend"><span class="refentrytitle">SetLegend</span></a>.
|
|
|
167 |
</p></li><li class="listitem"><p>
|
|
|
168 |
If the legend position is specified using device coordinates with
|
|
|
169 |
<a class="xref" href="SetLegendPixels.html" title="SetLegendPixels"><span class="refentrytitle">SetLegendPixels</span></a>, or by using
|
|
|
170 |
<a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a> (PHPlot-5.4.0 or later) with mode 'image'
|
|
|
171 |
or 'title', then the legend position is relative to the image.
|
|
|
172 |
The legend will be drawn at the specified position on the image,
|
|
|
173 |
once per plot, at the same location.
|
|
|
174 |
This repeated over-drawing is usually harmless,
|
|
|
175 |
but if you want to have it drawn only once,
|
|
|
176 |
either use <a class="xref" href="SetLegend.html" title="SetLegend"><span class="refentrytitle">SetLegend</span></a> only before the last plot,
|
|
|
177 |
or use either <code class="literal">SetLegend(NULL)</code>
|
|
|
178 |
or <code class="literal">SetLegend(array())</code>
|
|
|
179 |
to cancel the legend after the first plot.
|
|
|
180 |
</p></li><li class="listitem"><p>
|
|
|
181 |
If the legend position is specified using world coordinates with
|
|
|
182 |
<a class="xref" href="SetLegendWorld.html" title="SetLegendWorld"><span class="refentrytitle">SetLegendWorld</span></a>, or by using
|
|
|
183 |
<a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a> (PHPlot-5.4.0 or later) with mode 'world'
|
|
|
184 |
or 'plot', then the legend position is relative to the plot or the data
|
|
|
185 |
within the plot.
|
|
|
186 |
The legend will be drawn at the calculated position on each plot.
|
|
|
187 |
If using <a class="xref" href="SetLegendWorld.html" title="SetLegendWorld"><span class="refentrytitle">SetLegendWorld</span></a>, or
|
|
|
188 |
<a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a> with mode 'world', this assumes the
|
|
|
189 |
specified world coordinates are within the plot area for each plot.
|
|
|
190 |
As with the default positioning case, the same legend will be drawn for
|
|
|
191 |
each plot, unless the contents are changed with
|
|
|
192 |
<code class="function">SetLegend()</code>.
|
|
|
193 |
</p></li></ul></div><p>
|
|
|
194 |
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-background"></a>4.8.2.7. Plot Area Background</h4></div></div></div><p>
|
|
|
195 |
If you set a plot area background color with <a class="xref" href="SetPlotBgColor.html" title="SetPlotBgColor"><span class="refentrytitle">SetPlotBgColor</span></a>
|
|
|
196 |
and <a class="xref" href="SetDrawPlotAreaBackground.html" title="SetDrawPlotAreaBackground"><span class="refentrytitle">SetDrawPlotAreaBackground</span></a>,
|
|
|
197 |
or if you set a plot area background image with
|
|
|
198 |
<a class="xref" href="SetPlotAreaBgImage.html" title="SetPlotAreaBgImage"><span class="refentrytitle">SetPlotAreaBgImage</span></a>,
|
|
|
199 |
this will be applied to each plot until disabled.
|
|
|
200 |
This works well for side-by-side (tiled) plots, as each will get the same
|
|
|
201 |
background by default.
|
|
|
202 |
</p><p>
|
|
|
203 |
If you are overlaying multiple plots on an image, setting a plot area
|
|
|
204 |
background color or image for one plot will result in that background
|
|
|
205 |
hiding previous plots. Therefore, you need to set up the background for the
|
|
|
206 |
first plot, then turn it off it for the second plot.
|
|
|
207 |
If you previously set a plot area background image, you can disable it for
|
|
|
208 |
subsequent plots with <code class="literal">SetPlotAreaBgImage(NULL)</code>.
|
|
|
209 |
If you previously set and enabled a plot area background color, you can
|
|
|
210 |
disable it for subsequent plots with
|
|
|
211 |
<code class="literal">SetDrawPlotAreaBackground(FALSE)</code>.
|
|
|
212 |
</p></div><div class="sect3"><div class="titlepage"><div><div><h4 class="title"><a id="adv-multiplot-axis"></a>4.8.2.8. Axis Positioning</h4></div></div></div><p>
|
|
|
213 |
You can position the X and Y axis manually with
|
|
|
214 |
<a class="xref" href="SetXAxisPosition.html" title="SetXAxisPosition"><span class="refentrytitle">SetXAxisPosition</span></a> and <a class="xref" href="SetYAxisPosition.html" title="SetYAxisPosition"><span class="refentrytitle">SetYAxisPosition</span></a>,
|
|
|
215 |
or you can let PHPlot calculate the axis positions for you.
|
|
|
216 |
Whether you set the positions yourself, or let PHPlot calculate them for you,
|
|
|
217 |
those positions apply to subsequent plots unless overridden.
|
|
|
218 |
Even if you set a new data array, PHPlot will not recalculate the axis
|
|
|
219 |
positions unless told to.
|
|
|
220 |
</p><p>
|
|
|
221 |
If you want PHPlot to automatically re-calculate the X axis position for a
|
|
|
222 |
subsequent plot, use <code class="literal">SetXAxisPosition()</code> (with no
|
|
|
223 |
arguments), or <code class="literal">SetXAxisPosition('')</code>.
|
|
|
224 |
To restore automatic Y axis position calculation, use
|
|
|
225 |
<code class="literal">SetYAxisPosition()</code>
|
|
|
226 |
or <code class="literal">SetYAxisPosition('')</code>.
|
|
|
227 |
</p></div></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="adv-multiplot-tiled"></a>4.8.3. Summary - Tiled Multiple Plots</h3></div></div></div><p>
|
|
|
228 |
Here are some guidelines for tiling multiple plots:
|
|
|
229 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
|
|
230 |
Unless all plots will use the same X and Y data ranges, use
|
|
|
231 |
<a class="xref" href="SetPlotAreaWorld.html" title="SetPlotAreaWorld"><span class="refentrytitle">SetPlotAreaWorld</span></a> with each plot.
|
|
|
232 |
Call the function with no arguments to have PHPlot automatically calculate
|
|
|
233 |
the data range for the plot, or supply arguments to explicitly set a data range.
|
|
|
234 |
</p></li><li class="listitem"><p>
|
|
|
235 |
Use <a class="xref" href="SetPlotAreaPixels.html" title="SetPlotAreaPixels"><span class="refentrytitle">SetPlotAreaPixels</span></a> to set the area within the image
|
|
|
236 |
for each plot. Remember to leave room for axis labels and titles.
|
|
|
237 |
</p></li><li class="listitem"><p>
|
|
|
238 |
If you want a legend for each plot, use <a class="xref" href="SetLegendPixels.html" title="SetLegendPixels"><span class="refentrytitle">SetLegendPixels</span></a>,
|
|
|
239 |
<a class="xref" href="SetLegendWorld.html" title="SetLegendWorld"><span class="refentrytitle">SetLegendWorld</span></a>, or <a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a>
|
|
|
240 |
to position it.
|
|
|
241 |
Or let the position default to the upper right corner of each plot.
|
|
|
242 |
If instead you want a single legend, for example outside all the plot areas,
|
|
|
243 |
either set it up for the last plot, or
|
|
|
244 |
set it up for any plot and cancel it for the next plot.
|
|
|
245 |
Position the single legend with <a class="xref" href="SetLegendPixels.html" title="SetLegendPixels"><span class="refentrytitle">SetLegendPixels</span></a>,
|
|
|
246 |
or with <a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a> using any mode except 'world'.
|
|
|
247 |
</p></li><li class="listitem"><p>
|
|
|
248 |
You can only have one main title for the entire image.
|
|
|
249 |
</p></li></ul></div><p>
|
|
|
250 |
</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="adv-multiplot-overlay"></a>4.8.4. Summary - Overlay Multiple Plots</h3></div></div></div><p>
|
|
|
251 |
Here are some guidelines for overlaying multiple plots:
|
|
|
252 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
|
|
253 |
All plots will use the same data scaling by default, whether automatically
|
|
|
254 |
calculated by PHPlot or set with <a class="xref" href="SetPlotAreaWorld.html" title="SetPlotAreaWorld"><span class="refentrytitle">SetPlotAreaWorld</span></a>.
|
|
|
255 |
Use <a class="xref" href="SetPlotAreaWorld.html" title="SetPlotAreaWorld"><span class="refentrytitle">SetPlotAreaWorld</span></a> if you want different data scaling
|
|
|
256 |
for subsequent plots.
|
|
|
257 |
</p></li><li class="listitem"><p>
|
|
|
258 |
You can let PHPlot calculate the plot window by default, but it will not
|
|
|
259 |
account for additional margin space needed by plots after the first.
|
|
|
260 |
Instead, you can use <a class="xref" href="SetPlotAreaPixels.html" title="SetPlotAreaPixels"><span class="refentrytitle">SetPlotAreaPixels</span></a> or
|
|
|
261 |
<a class="xref" href="SetMarginsPixels.html" title="SetMarginsPixels"><span class="refentrytitle">SetMarginsPixels</span></a>
|
|
|
262 |
to set a specific plot area to use for all plots.
|
|
|
263 |
</p></li><li class="listitem"><p>
|
|
|
264 |
Set the tick increments you want for each plot, especially if the data
|
|
|
265 |
ranges differ. You can have two sets of tick marks and labels if you position
|
|
|
266 |
them on the opposite sides of the plot area.
|
|
|
267 |
</p></li><li class="listitem"><p>
|
|
|
268 |
Draw grid lines, if you want them, only for the first plot, and turn them
|
|
|
269 |
off for the second plot.
|
|
|
270 |
</p></li><li class="listitem"><p>
|
|
|
271 |
If you want a single legend, either set it up for the last plot, or
|
|
|
272 |
set it up for any plot and cancel it for the next plot.
|
|
|
273 |
If you want multiple legends, one per overlay, position them
|
|
|
274 |
manually with <a class="xref" href="SetLegendWorld.html" title="SetLegendWorld"><span class="refentrytitle">SetLegendWorld</span></a>,
|
|
|
275 |
<a class="xref" href="SetLegendPixels.html" title="SetLegendPixels"><span class="refentrytitle">SetLegendPixels</span></a>, or <a class="xref" href="SetLegendPosition.html" title="SetLegendPosition"><span class="refentrytitle">SetLegendPosition</span></a>.
|
|
|
276 |
</p></li><li class="listitem"><p>
|
|
|
277 |
If you want a plot area background, you must set it for the first plot
|
|
|
278 |
and cancel it for the second plot, or it will hide the plots.
|
|
|
279 |
</p></li></ul></div><p>
|
|
|
280 |
</p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a id="adv-multiplot-history"></a>4.8.5. Multiple Plots - History</h3></div></div></div><p>
|
|
|
281 |
A number of fixes were made in PHPlot-5.3.1 that affect multiple plots
|
|
|
282 |
per image. If you are creating multiple plot images using PHPlot-5.3.0 or
|
|
|
283 |
earlier, you should upgrade to the latest release. If you are unable to
|
|
|
284 |
upgrade, you may need to work around the following issues:
|
|
|
285 |
|
|
|
286 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
|
|
|
287 |
Color allocation: In PHPlot-5.2.0 and PHPlot-5.3.0, the data color array
|
|
|
288 |
(whether defaulted or set with <a class="xref" href="SetDataColors.html" title="SetDataColors"><span class="refentrytitle">SetDataColors</span></a>) was truncated
|
|
|
289 |
to the number of colors required for a plot.
|
|
|
290 |
This means that the additional colors were not available for subsequent plots,
|
|
|
291 |
so the data colors would repeat.
|
|
|
292 |
For example, if plot #1 used 3 colors for 3 data sets, and plot #2 had 5
|
|
|
293 |
data sets, only 3 colors were available and the first two colors would be
|
|
|
294 |
reused for the 4th and 5th data sets.
|
|
|
295 |
To work around this, you can reload the data colors before each subsequent plot.
|
|
|
296 |
To reload the default data colors, use
|
|
|
297 |
<code class="literal">$plot->SetDataColors(False)</code>.
|
|
|
298 |
Another work-around is to define a custom data color callback, which
|
|
|
299 |
turns off the color slot optimization.
|
|
|
300 |
</p></li><li class="listitem"><p>
|
|
|
301 |
Legend positioning using <a class="xref" href="SetLegendWorld.html" title="SetLegendWorld"><span class="refentrytitle">SetLegendWorld</span></a> was not correctly
|
|
|
302 |
applied to subsequent plots in an image through PHPlot-5.3.0.
|
|
|
303 |
If you have multiple side-by-side plots and you want the legend in the same
|
|
|
304 |
world coordinate position in each plot, you still need to use
|
|
|
305 |
<code class="literal">SetLegendWorld(..., ...)</code> when creating each plot.
|
|
|
306 |
</p></li><li class="listitem"><p>
|
|
|
307 |
Through PHPlot-5.3.0, there was no way to reset the X axis position or Y
|
|
|
308 |
axis position to the default of automatic positioning.
|
|
|
309 |
That is, <code class="literal">SetXAxisPosition()</code>,
|
|
|
310 |
<code class="literal">SetXAxisPosition('')</code>,
|
|
|
311 |
<code class="literal">SetYAxisPosition()</code>,
|
|
|
312 |
and <code class="literal">SetYAxisPosition('')</code> did not work.
|
|
|
313 |
There is no work-around to get automatic positioning of the axis lines.
|
|
|
314 |
</p></li><li class="listitem"><p>
|
|
|
315 |
Through PHPlot-5.3.0, several functions had more restricted usage
|
|
|
316 |
when resetting to defaults.
|
|
|
317 |
</p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: circle; "><li class="listitem"><p>
|
|
|
318 |
Use <code class="literal">SetLegendPixels(NULL, NULL)</code>
|
|
|
319 |
rather than <code class="literal">SetLegendPixels()</code>.
|
|
|
320 |
</p></li><li class="listitem"><p>
|
|
|
321 |
Use <code class="literal">SetNumXTicks('')</code> and <code class="literal">SetNumYTicks('')</code>
|
|
|
322 |
rather than <code class="literal">SetNumXTicks()</code> and
|
|
|
323 |
<code class="literal">SetNumYTicks()</code>.
|
|
|
324 |
</p></li><li class="listitem"><p>
|
|
|
325 |
Use <code class="literal">SetLegend(array())</code>
|
|
|
326 |
rather than <code class="literal">SetLegend(NULL)</code>.
|
|
|
327 |
</p></li></ul></div><p>
|
|
|
328 |
</p></li></ul></div><p>
|
|
|
329 |
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="adv-tuning.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="advanced.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="adv-streaming.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">4.7. Tuning Parameters </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> 4.9. Streaming Plots</td></tr></table></div></body></html>
|