| 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="824Adjustingthealignmentofbarsonatextscale.html">
|
|
|
8 |
<LINK REL="Next" HREF="826Usingaccumulatedbarplots.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="824Adjustingthealignmentofbarsonatextscale.html">Previous</A>
|
|
|
26 |
<A HREF="826Usingaccumulatedbarplots.html">Next</A>
|
|
|
27 |
<HR NOSHADE>
|
|
|
28 |
<H3><A NAME="8_2_5">8.2.5 Using grouped bar plots</A></H3>
|
|
|
29 |
<P> These types of bar graph is used to easy group two or more bars
|
|
|
30 |
together around each tick (X-value). The bars will be placed
|
|
|
31 |
immediately beside each other and as a group centered on each tick
|
|
|
32 |
mark. A grouped bar is created by aggregating two or more ordinary bar
|
|
|
33 |
graphs and creating a <A href="../ref/GroupBarPlot.html#_C_GROUPBARPLOT">
|
|
|
34 |
GroupBarPlot()</A> From two ordinary bar graphs along the lines of<DIV class="phpscript">
|
|
|
35 |
<CODE><FONT color="#000000"> <FONT color="#0000BB"> </FONT><FONT color="#FF8000">
|
|
|
36 |
// Create the bar plots
|
|
|
37 |
<BR></FONT><FONT color="#0000BB">$b1plot </FONT><FONT color="#007700">
|
|
|
38 |
= new </FONT><FONT color="#0000BB">BarPlot</FONT><FONT color="#007700">(</FONT><FONT
|
|
|
39 |
color="#0000BB">$data1y</FONT><FONT color="#007700">);
|
|
|
40 |
<BR></FONT><FONT color="#0000BB">$b1plot</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
41 |
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
|
|
|
42 |
"orange"</FONT><FONT color="#007700">);
|
|
|
43 |
<BR>
|
|
|
44 |
<BR></FONT><FONT color="#0000BB">$b2plot </FONT><FONT color="#007700">
|
|
|
45 |
= new </FONT><FONT color="#0000BB">BarPlot</FONT><FONT color="#007700">(</FONT><FONT
|
|
|
46 |
color="#0000BB">$data2y</FONT><FONT color="#007700">);
|
|
|
47 |
<BR></FONT><FONT color="#0000BB">$b2plot</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
48 |
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
|
|
|
49 |
"blue"</FONT><FONT color="#007700">);
|
|
|
50 |
<BR>
|
|
|
51 |
<BR></FONT><FONT color="#FF8000">// Create the grouped bar plot
|
|
|
52 |
<BR></FONT><FONT color="#0000BB">$gbplot </FONT><FONT color="#007700">
|
|
|
53 |
= new </FONT><FONT color="#0000BB">GroupBarPlot</FONT><FONT color="#007700">
|
|
|
54 |
(array(</FONT><FONT color="#0000BB">$b1plot</FONT><FONT color="#007700">
|
|
|
55 |
,</FONT><FONT color="#0000BB">$b2plot</FONT><FONT color="#007700">));
|
|
|
56 |
<BR>
|
|
|
57 |
<BR></FONT><FONT color="#FF8000">// ...and add it to the graPH
|
|
|
58 |
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-></FONT><FONT
|
|
|
59 |
color="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
|
|
|
60 |
$gbplot</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
|
|
|
61 |
</FONT></CODE></DIV></P>
|
|
|
62 |
<P> The following example illustrates this type of graph<DIV class="example">
|
|
|
63 |
<BR> <A href="exframes/frame_example21.html" target="blank"><IMG border="0"
|
|
|
64 |
HEIGHT="200" src="img/example21.png" WIDTH="310"></A>
|
|
|
65 |
<BR><B>Figure 36:</B> A grouped bar plot <A href="exframes/frame_example21.html"
|
|
|
66 |
target="blank">[src]</A>
|
|
|
67 |
<P></P>
|
|
|
68 |
</DIV></P>
|
|
|
69 |
<P> There is no limit on the number of plots you may group together.</P>
|
|
|
70 |
<P> If you use the SetWidth() method on the GroupBarPlot() this will
|
|
|
71 |
affect the total width used by all the added plots. Each individual bar
|
|
|
72 |
width will be the same for all added bars. The default width for
|
|
|
73 |
grouped bar is 70%.</P>
|
|
|
74 |
<P> Setting the grouped with to 0.9 would result in the image below.<DIV class="example">
|
|
|
75 |
<BR> <A href="exframes/frame_example22.html" target="blank"><IMG border="0"
|
|
|
76 |
HEIGHT="200" src="img/example22.png" WIDTH="310"></A>
|
|
|
77 |
<BR><B>Figure 37:</B> Adjusting the width for a gropued bar plot. <A href="exframes/frame_example22.html"
|
|
|
78 |
target="blank">[src]</A>
|
|
|
79 |
<P></P>
|
|
|
80 |
</DIV></P>
|
|
|
81 |
<P></P>
|
|
|
82 |
<HR NOSHADE>
|
|
|
83 |
<A HREF="toc.html">Contents</A>
|
|
|
84 |
<A HREF="824Adjustingthealignmentofbarsonatextscale.html">Previous</A>
|
|
|
85 |
<A HREF="826Usingaccumulatedbarplots.html">Next</A>
|
|
|
86 |
</BODY>
|
|
|
87 |
</HTML>
|