Graphics Reference
In-Depth Information
Figure 7-14. Left: error bars on a bar graph; right: on a line graph
Discussion
In this example, the data already has values for the standard error of the mean (
se
), which we'll
use for the error bars (it also has values for the standard deviation,
sd
, but we're not using that
here):
ce
Cultivar Date Weight sd n se
c39 d16
3.18 0.9566144 10 0.30250803
c39 d20
2.80 0.2788867 10 0.08819171
c39 d21
2.74 0.9834181 10 0.31098410
To get the values for
ymax
and
ymin
, we took the y variable,
Weight
, and added/subtracted
se
.
We also specified the width of the ends of the error bars, with
width=.2
. It's best to play around
with this to find a value that looks good. If you don't set the width, the error bars will be very
wide, spanning all the space between items on the x-axis.
For a bar graph with groups of bars, the error bars must also be dodged; otherwise, they'll have
the exact same xcoordinate and won't line up with the bars. (See
Grouping Bars Together
for
more information about grouped bars and dodging.)
We'll work with the full
cabbage_exp
data set this time:
cabbage_exp
Cultivar Date Weight sd n se
c39 d16
3.18 0.9566144 10 0.30250803