Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2
<HTML>
3
<HEAD>
4
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
5
<LINK REL="Start" HREF="index.html">
6
<LINK REL="Contents" HREF="toc.html">
7
<LINK REL="Prev" HREF="812Displayingthevaluesforeachdatapoint.html">
8
<LINK REL="Next" HREF="814AddingasecondYscale.html">
9
<STYLE TYPE="text/css"><!--
10
BODY { font-family: serif }
11
H1 { font-family: sans-serif }
12
H2 { font-family: sans-serif }
13
H3 { font-family: sans-serif }
14
H4 { font-family: sans-serif }
15
H5 { font-family: sans-serif }
16
H6 { font-family: sans-serif }
17
SUB { font-size: smaller }
18
SUP { font-size: smaller }
19
PRE { font-family: monospace }
20
A { text-decoration: none }
21
--></STYLE>
22
</HEAD>
23
<BODY>
24
<A HREF="toc.html">Contents</A>
25
<A HREF="812Displayingthevaluesforeachdatapoint.html">Previous</A>
26
<A HREF="814AddingasecondYscale.html">Next</A>
27
<HR NOSHADE>
28
<H3><A NAME="8_1_3">8.1.3 Adding several plots to the same graph</A></H3>
29
<P> What if we want to add a second plot to the graph we just produced?
30
 Well, this is quite straightforward and just requires two simple step:</P>
31
<OL>
32
<LI>Create the second plot</LI>
33
<LI>Add it to the graph</LI>
34
</OL>
35
<P> To create the second plot we need some data (we could of course use
36
 the same data as for the first plot but then we wouldn't be able to see
37
 the new plot!)</P>
38
<P> The following lines show how to create the new plot and add it to
39
 the graph (we only show the new lines - not the full script)<DIV class="phpscript">
40
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$ydata2&nbsp;</FONT><FONT color="#007700">
41
=&nbsp;array(</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
42
color="#0000BB">19</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
43
15</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">7</FONT><FONT
44
color="#007700">,</FONT><FONT color="#0000BB">22</FONT><FONT color="#007700">
45
,</FONT><FONT color="#0000BB">14</FONT><FONT color="#007700">,</FONT><FONT
46
color="#0000BB">5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
47
9</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">21</FONT><FONT
48
color="#007700">,</FONT><FONT color="#0000BB">13</FONT><FONT color="#007700">
49
);
50
<BR></FONT><FONT color="#0000BB">$lineplot2</FONT><FONT color="#007700">
51
=new&nbsp;</FONT><FONT color="#0000BB">LinePlot</FONT><FONT color="#007700">(</FONT><FONT
52
color="#0000BB">$ydata2</FONT><FONT color="#007700">);
53
<BR></FONT><FONT color="#0000BB">$lineplot2</FONT><FONT color="#007700">
54
-&gt;</FONT><FONT color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT
55
color="#DD0000">&quot;orange&quot;</FONT><FONT color="#007700">);
56
<BR></FONT><FONT color="#0000BB">$lineplot2</FONT><FONT color="#007700">
57
-&gt;</FONT><FONT color="#0000BB">SetWeight</FONT><FONT color="#007700">(</FONT><FONT
58
color="#0000BB">2</FONT><FONT color="#007700">);
59
<BR>
60
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
61
color="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
62
$lineplot2</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
63
</FONT></CODE></DIV></P>
64
<P> Making these changes to the previous graph script would generate a
65
 new graph as illustrated below.<DIV class="example">
66
<BR> <A href="exframes/frame_example4.html" target="blank"><IMG border="0"
67
HEIGHT="200"  src="img/example4.png" WIDTH="300"></A>
68
<BR><B>Figure 9:</B> Adding a second plot to the previous graph <A href="exframes/frame_example4.html"
69
target="blank">[src]</A>&nbsp;
70
<P></P>
71
</DIV></P>
72
<P> There is a few things worth noting here</P>
73
<UL>
74
<LI>The Y-scale has changed to accommodate the larger range of Y-values
75
 for the second graph.</LI>
76
<LI>If you add several plots to the same graph they should contain the
77
 same number of data points. This is not a requirement (the graph will
78
 be automatically scaled to accommodate the plot with the largest number
79
 of points) but it will not look very good since one of the plot end in
80
 the middle of the graph.</LI>
81
</UL>
82
<P></P>
83
<HR NOSHADE>
84
<A HREF="toc.html">Contents</A>
85
<A HREF="812Displayingthevaluesforeachdatapoint.html">Previous</A>
86
<A HREF="814AddingasecondYscale.html">Next</A>
87
</BODY>
88
</HTML>