Blame | Letzte Änderung | Log anzeigen | RSS feed
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1"><LINK REL="Start" HREF="index.html"><LINK REL="Contents" HREF="toc.html"><LINK REL="Prev" HREF="8114Usingfilledlinegraphs.html"><LINK REL="Next" HREF="8116ConstructingsmoothlineplotswithCubicSplines.html"><STYLE TYPE="text/css"><!--BODY { font-family: serif }H1 { font-family: sans-serif }H2 { font-family: sans-serif }H3 { font-family: sans-serif }H4 { font-family: sans-serif }H5 { font-family: sans-serif }H6 { font-family: sans-serif }SUB { font-size: smaller }SUP { font-size: smaller }PRE { font-family: monospace }A { text-decoration: none }--></STYLE></HEAD><BODY><A HREF="toc.html">Contents</A><A HREF="8114Usingfilledlinegraphs.html">Previous</A><A HREF="8116ConstructingsmoothlineplotswithCubicSplines.html">Next</A><HR NOSHADE><H3><A NAME="8_1_15">8.1.15 Using accumulated line graphs</A></H3><P> Accumulated line graphs are line graphs that are "stacked" on top ofeach other. That is, the values in the supplied data for the Y-axis isnot the absolute value but rather the relative value from graph below.For example if you have two line graphs with three points each, say[3,7,5] and [6,9,7]. The first graph will be plotted on the absoluteY-values [3,7,5] the second plot will be plotted at [3+6, 7+9, 5+7],hence the values of the previous graphs will be used as offsets.</P><P> You may add any number of ordinary line graphs together. If you wantto use three line plots in an accumulated line plot graph you write thefollowing code</P><P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB"> </FONT><FONT color="#FF8000">// First create the individual plots<BR></FONT><FONT color="#0000BB">$p1 </FONT><FONT color="#007700">= new </FONT><FONTcolor="#0000BB">LinePlot</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$datay_1</FONT><FONT color="#007700">);<BR></FONT><FONT color="#0000BB">$p2 </FONT><FONT color="#007700">= new </FONT><FONTcolor="#0000BB">LinePlot</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$datay_2</FONT><FONT color="#007700">);<BR></FONT><FONT color="#0000BB">$p3 </FONT><FONT color="#007700">= new </FONT><FONTcolor="#0000BB">LinePlot</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$datay_3</FONT><FONT color="#007700">);<BR><BR></FONT><FONT color="#FF8000">// Then add them together to form a accumulated plot<BR></FONT><FONT color="#0000BB">$ap </FONT><FONT color="#007700">= new </FONT><FONTcolor="#0000BB">AccLinePlot</FONT><FONT color="#007700">(array(</FONT><FONTcolor="#0000BB">$p1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$p2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$p3</FONT><FONTcolor="#007700">));<BR><BR></FONT><FONT color="#FF8000">// Add the accumulated line plot to the graph<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$ap</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P><P> You might of course also fill each line plot by adding the lines<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB"> $p1</FONT><FONT color="#007700">-></FONT><FONT color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">"red"</FONT><FONT color="#007700">);<BR></FONT><FONT color="#0000BB">$p2</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">"blue"</FONT><FONT color="#007700">);<BR></FONT><FONT color="#0000BB">$p3</FONT><FONT color="#007700">-></FONT><FONTcolor="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">"green"</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P><P> Using some appropriate data this might then give a graph perhapslike the one showed in the figure below<DIV class="example"><BR> <A href="exframes/frame_example17.html" target="blank"><IMG border="0"HEIGHT="200" src="img/example17.png" WIDTH="300"></A><BR><B>Figure 25:</B> Accumulated filled line graph <A href="exframes/frame_example17.html"target="blank">[src]</A> <P></P></DIV></P><P></P><HR NOSHADE><A HREF="toc.html">Contents</A><A HREF="8114Usingfilledlinegraphs.html">Previous</A><A HREF="8116ConstructingsmoothlineplotswithCubicSplines.html">Next</A></BODY></HTML>