| 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="7114Usingfilledlinegraphs.html">
|
|
|
8 |
<LINK REL="Next" HREF="7116ConstructingsmoothlineplotswithCubicSplines.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="7114Usingfilledlinegraphs.html">Previous</A>
|
|
|
26 |
<A HREF="7116ConstructingsmoothlineplotswithCubicSplines.html">Next</A>
|
|
|
27 |
<HR NOSHADE>
|
|
|
28 |
<H3><A NAME="7_1_15">7.1.15 Using accumulated line graphs</A></H3>
|
|
|
29 |
<P> Accumulated line graphs are line graphs that are "stacked" on top of
|
|
|
30 |
each other. That is, the values in the supplied data for the Y-axis is
|
|
|
31 |
not the absolute value but rather the relative value from graph below.
|
|
|
32 |
For example if you have two line graphs with three points each, say
|
|
|
33 |
[3,7,5] and [6,9,7]. The first graph will be plotted on the absolute
|
|
|
34 |
Y-values [3,7,5] the second plot will be plotted at [3+6, 7+9, 5+7],
|
|
|
35 |
hence the values of the previous graphs will be used as offsets.</P>
|
|
|
36 |
<P> You may add any number of ordinary line graphs together. If you want
|
|
|
37 |
to use three line plots in an accumulated line plot graph you write the
|
|
|
38 |
following code</P>
|
|
|
39 |
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
|
|
|
40 |
</FONT><FONT color="#FF8000">// First create the individual plots
|
|
|
41 |
<BR></FONT><FONT color="#0000BB">$p1 </FONT><FONT color="#007700">= new </FONT><FONT
|
|
|
42 |
color="#0000BB">LinePlot</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
|
|
|
43 |
$datay_1</FONT><FONT color="#007700">);
|
|
|
44 |
<BR></FONT><FONT color="#0000BB">$p2 </FONT><FONT color="#007700">= new </FONT><FONT
|
|
|
45 |
color="#0000BB">LinePlot</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
|
|
|
46 |
$datay_2</FONT><FONT color="#007700">);
|
|
|
47 |
<BR></FONT><FONT color="#0000BB">$p3 </FONT><FONT color="#007700">= new </FONT><FONT
|
|
|
48 |
color="#0000BB">LinePlot</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
|
|
|
49 |
$datay_3</FONT><FONT color="#007700">);
|
|
|
50 |
<BR>
|
|
|
51 |
<BR></FONT><FONT color="#FF8000">
|
|
|
52 |
// Then add them together to form a accumulated plot
|
|
|
53 |
<BR></FONT><FONT color="#0000BB">$ap </FONT><FONT color="#007700">= new </FONT><FONT
|
|
|
54 |
color="#0000BB">AccLinePlot</FONT><FONT color="#007700">(array(</FONT><FONT
|
|
|
55 |
color="#0000BB">$p1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
|
|
|
56 |
$p2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$p3</FONT><FONT
|
|
|
57 |
color="#007700">));
|
|
|
58 |
<BR>
|
|
|
59 |
<BR></FONT><FONT color="#FF8000">
|
|
|
60 |
// Add the accumulated line plot to the graph
|
|
|
61 |
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
62 |
color="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
|
|
|
63 |
$ap</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT>
|
|
|
64 |
</CODE></DIV></P>
|
|
|
65 |
<P> You might of course also fill each line plot by adding the lines<DIV class="phpscript">
|
|
|
66 |
<CODE><FONT color="#000000"> <FONT color="#0000BB"> $p1</FONT><FONT color="#007700">
|
|
|
67 |
-></FONT><FONT color="#0000BB">SetFillColor</FONT><FONT color="#007700">
|
|
|
68 |
(</FONT><FONT color="#DD0000">"red"</FONT><FONT color="#007700">);
|
|
|
69 |
<BR></FONT><FONT color="#0000BB">$p2</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
70 |
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
|
|
|
71 |
"blue"</FONT><FONT color="#007700">);
|
|
|
72 |
<BR></FONT><FONT color="#0000BB">$p3</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
73 |
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
|
|
|
74 |
"green"</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
|
|
|
75 |
</FONT></CODE></DIV></P>
|
|
|
76 |
<P> Using some appropriate data this might then give a graph perhaps
|
|
|
77 |
like the one showed in the figure below<DIV class="example">
|
|
|
78 |
<BR> <A href="exframes/frame_example17.html" target="blank"><IMG border="0"
|
|
|
79 |
HEIGHT="200" src="img/img/img/img/img/img/example17.png" WIDTH="300"></A>
|
|
|
80 |
<BR><B>Figure 27:</B> Accumulated filled line graph <A href="exframes/frame_example17.html"
|
|
|
81 |
target="blank">[src]</A>
|
|
|
82 |
<P></P>
|
|
|
83 |
</DIV></P>
|
|
|
84 |
<P></P>
|
|
|
85 |
<HR NOSHADE>
|
|
|
86 |
<A HREF="toc.html">Contents</A>
|
|
|
87 |
<A HREF="7114Usingfilledlinegraphs.html">Previous</A>
|
|
|
88 |
<A HREF="7116ConstructingsmoothlineplotswithCubicSplines.html">Next</A>
|
|
|
89 |
</BODY>
|
|
|
90 |
</HTML>
|