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="813Addingseveralplotstothesamegraph.html">
8
<LINK REL="Next" HREF="815Addingalegendtothegraph.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="813Addingseveralplotstothesamegraph.html">Previous</A>
26
<A HREF="815Addingalegendtothegraph.html">Next</A>
27
<HR NOSHADE>
28
<H3><A NAME="8_1_4">8.1.4 Adding a second Y-scale</A></H3>
29
<P> As you saw in the preceding example you could add multiple plots to
30
 the same graph and Y-axis. However what if the two plots you want to
31
 display in the graph has very different ranges. One might for example
32
 have Y-values like above but the other might have Y-values in the
33
 100:s. Even though it is perfectly possible to add them as above the
34
 graph with the smallest values will have a very low dynamic range since
35
 the scale must accomplish the bigger dynamic range of the second plot.</P>
36
<P> The solution to this is to use a second Y-axis with a different
37
 scale and add the second plot to this Y-axis instead. Let's take a look
38
 at how that is accomplished.</P>
39
<P> First we need to create a new data array with large values and
40
 secondly we need to specify a scale for the Y2 axis. This is done by
41
 the lines<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
42
&nbsp;$y2data&nbsp;</FONT><FONT color="#007700">=&nbsp;array(</FONT><FONT color="#0000BB">
43
354</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT
44
color="#007700">,</FONT><FONT color="#0000BB">265</FONT><FONT color="#007700">
45
,</FONT><FONT color="#0000BB">99</FONT><FONT color="#007700">,</FONT><FONT
46
color="#0000BB">111</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
47
91</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">198</FONT><FONT
48
color="#007700">,</FONT><FONT color="#0000BB">225</FONT><FONT color="#007700">
49
,</FONT><FONT color="#0000BB">293</FONT><FONT color="#007700">,</FONT><FONT
50
color="#0000BB">251</FONT><FONT color="#007700">);
51
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
52
color="#0000BB">SetY2Scale</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
53
&quot;lin&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT>
54
</CODE></DIV></P>
55
<P> and finally we create a new line plot and add that to the second
56
 Y-axis. Note that we here use a new method, AddY2(), since we want this
57
 plot to be added to the second Y-axis. Note that JpGraph will only
58
 support two different Y-axis. This is not considered a limitation since
59
 using more than two scales in the same graph would make it very
60
 difficult to interpret the meaning of the graph.</P>
61
<P> To make the graph a little bit more esthetic pleasing we use
62
 different colors for the different plots and let the two different
63
 Y-axis get the same colors as the plots.</P>
64
<P> The resulting graph is shown below. source)<DIV class="example">
65
<BR> <A href="exframes/frame_example5.html" target="blank"><IMG border="0"
66
HEIGHT="200"  src="img/example5.png" WIDTH="300"></A>
67
<BR><B>Figure 10:</B> Adding a second Y-scale plot to the same graph <A href="exframes/frame_example5.html"
68
target="blank">[src]</A>&nbsp;
69
<P></P>
70
</DIV></P>
71
<P></P>
72
<HR NOSHADE>
73
<A HREF="toc.html">Contents</A>
74
<A HREF="813Addingseveralplotstothesamegraph.html">Previous</A>
75
<A HREF="815Addingalegendtothegraph.html">Next</A>
76
</BODY>
77
</HTML>