plotCI.html
6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>R: Plot Error Bars and Confidence Intervals</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="../../R.css">
</head><body>
<table width="100%" summary="page for plotCI {gplots}"><tr><td>plotCI {gplots}</td><td align="right">R Documentation</td></tr></table>
<h2>Plot Error Bars and Confidence Intervals</h2>
<h3>Description</h3>
<p>
Given a set of x and y values and interval width or upper and lower bounds,
plot the points with error bars. This can be a useful tool for
visualizing confidence intervals.
</p>
<h3>Usage</h3>
<pre>
plotCI(x, y = NULL, uiw, liw = uiw, ui, li, err='y', ylim=NULL,
xlim=NULL, type="p", col=par("col"), barcol=col,
pt.bg = par("bg"), sfrac = 0.01, gap=1, lwd=par("lwd"),
lty=par("lty"), labels=FALSE, add=FALSE, xlab, ylab, minbar,
maxbar, ... )
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x,y</code></td>
<td>
coordinates for the center of error bars. <code>y</code>
defaults to <code>1:n</code>.</td></tr>
<tr valign="top"><td><code>uiw</code></td>
<td>
width of the upper or right error bar. Set to <code>NULL</code>
omit upper bars.</td></tr>
<tr valign="top"><td><code>liw</code></td>
<td>
width of the lower or left error bar. Defaults to same value as
<code>uiw</code>. Set to <code>NULL</code> to omit lower bars. </td></tr>
<tr valign="top"><td><code>ui</code></td>
<td>
upper end of error bars. Defaults to <code>y + uiw</code> or
<code>x + uiw</code> depeding on <code>err</code>. Set to <code>NULL</code> omit
upper bars. </td></tr>
<tr valign="top"><td><code>li</code></td>
<td>
lower end of error bars. Defaults to <code>y - liw</code> or
<code>x - liw</code> depedning on <code>err</code>. Set to <code>NULL</code> to omit
lower bars.</td></tr>
<tr valign="top"><td><code>err</code></td>
<td>
direction for error bars. Set to "y" for vertical bars.
Set to "x" for horizontal bars. Defaults to "y".</td></tr>
<tr valign="top"><td><code>col</code></td>
<td>
color of plotting character used center marker of error
bars. Default is "black".</td></tr>
<tr valign="top"><td><code>xlim, ylim</code></td>
<td>
range of x/y values to include in the plotting area. </td></tr>
<tr valign="top"><td><code>type</code></td>
<td>
point/line type; passed to <code><a href="../../graphics/html/points.html">points</a></code></td></tr>
<tr valign="top"><td><code>barcol</code></td>
<td>
color of the error bars. Defaults to the same value as
<code>col</code> </td></tr>
<tr valign="top"><td><code>pt.bg</code></td>
<td>
background color of points (use
<code>pch=21, pt.bg=par("bg")</code> to get open points superimposed on
error bars).</td></tr>
<tr valign="top"><td><code>sfrac</code></td>
<td>
width of "crossbar" at the end of error bar as a fraction
of the x plotting region. Defaults to 0.01. </td></tr>
<tr valign="top"><td><code>gap</code></td>
<td>
space left between the center of the error bar and the
lines marking the error bar in units of the height (width) of the
letter "O". Defaults to 1.0 </td></tr>
<tr valign="top"><td><code>lwd</code></td>
<td>
width of bar lines. </td></tr>
<tr valign="top"><td><code>lty</code></td>
<td>
line type of bar lines. </td></tr>
<tr valign="top"><td><code>labels</code></td>
<td>
either a logical value indicating whether the circles
representing the x values should be replaced with text giving the
actual values or a vector containing labels to use
instead. Defaults to <code>FALSE</code>. </td></tr>
<tr valign="top"><td><code>add</code></td>
<td>
logical indicating whether error bars should be added to
the current plot. If <code>FALSE</code> (the defailt), a new plot will be
created and symbols/labels for the x values will be plotted before
drawing error bars.</td></tr>
<tr valign="top"><td><code>minbar</code></td>
<td>
minumum allowed value for bar ends. If specified,
values smaller than <code>minbar</code> will be replaced with
<code>minbar</code>. </td></tr>
<tr valign="top"><td><code>maxbar</code></td>
<td>
maximum allowed value for bar ends. If specified,
values larger than <code>maxbar</code> will be replaced with
<code>maxbar</code>. </td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
optional plotting parameters </td></tr>
<tr valign="top"><td><code>xlab</code></td>
<td>
label for x axis. </td></tr>
<tr valign="top"><td><code>ylab</code></td>
<td>
label for y axis. </td></tr>
</table>
<h3>Author(s)</h3>
<p>
Original version by Bill Venables
<a href="mailto:wvenable@attunga.stats.adelaide.edu.au">wvenable@attunga.stats.adelaide.edu.au</a> posted to r-help on
Sep. 20, 1997. Enhanced version posted to r-help by Ben Bolker
<a href="mailto:ben@zoo.ufl.edu">ben@zoo.ufl.edu</a> on Apr. 16, 2001. This version was modified
and extended by Gregory R. Warnes
<a href="mailto:warnes@bst.rochester.edu">warnes@bst.rochester.edu</a>. Additional changes
suggested by Martin Maechler <a href="mailto:maechler@stat.math.ethz.ch">maechler@stat.math.ethz.ch</a>
integrated on July 29, 2004.
</p>
<h3>See Also</h3>
<p>
<code><a href="plotmeans.html">plotmeans</a></code> provides an enhanced wrapper to
<code>plotCI</code>.
</p>
<h3>Examples</h3>
<pre>
# plot means and
data(state)
tmp <- split(state.area, state.region)
means <- sapply(tmp, mean)
stdev <- sqrt(sapply(tmp, var))
n <- sapply(tmp,length)
ciw <- qt(0.975, n) * stdev / sqrt(n)
# plain
plotCI(x=means, uiw=ciw)
# prettier
plotCI(x=means, uiw=ciw, col="black", barcol="blue", lwd=1)
# give mean values
plotCI(x=means, uiw=ciw, col="black", barcol="blue",
labels=round(means,-3), xaxt="n", xlim=c(0,5) )
axis(side=1, at=1:4, labels=names(tmp), cex=0.7)
# better yet, just use plotmeans ... #
plotmeans( state.area ~ state.region )
</pre>
<hr><div align="center">[Package <em>gplots</em> version 2.3.2 <a href="00Index.html">Index]</a></div>
</body></html>