plot-methods {acs} | R Documentation |
acs Methods for Function plot
Description
Plot acs objects, with both estimates and confidence intervals.
Usage
## S4 method for signature 'acs'
plot(x, conf.level=.95, err.col="red", err.lwd=1,
err.pch="-", err.cex=2, err.lty=2, x.res=300, labels="auto",
by="geography", true.min=T, ...)
Arguments
x |
the acs object to be plotted |
conf.level |
the desired confidence interval to use for error bars; numeric between 0<1 |
err.col |
the color to use for the error bars; analogous to
graphic parameter |
err.lwd |
the line weight to use for the error bars; analogous to
graphic parameter |
err.pch |
the point character to use for the error bars; analogous to
graphic parameter |
err.cex |
the scaling factor to use for the error bars; analogous to
graphic parameter |
err.lty |
the line type to use for the error bars; analogous to
graphic parameter |
x.res |
when plot called with a single acs value (see below), x.res determines the resolution of the resulting density plot; integer (defaults to 300, i.e., the curve is drawn with 300 points) |
labels |
the labels to use for the x axis; defaults to either geography names or acs.colnames based on dimensions of object plotted; vector of proper length required |
by |
in cases where multiple rows and columns are plotted,
whether to provide a different plot for each value of |
true.min |
whether to limit the lower bound of a confidence
interval to some value or now; |
... |
provided to allow for passing of additional arguments to plot functions |
Methods
signature(object = "acs")
-
When passed an acs object (possibly involving subsetting),
plot
will call a plot showing both estimates and confidence intervals for the data contained in the object.If the object contains only one row or only one column,
plot
will use this dimension as the y-axis and will plot each observation along the x-axis, as three points (an estimate bracketed by upper and lower confidence bounds). If the object contains multiple rows and columns,plot
will return a 1-by-y "plot of plots": by default there will be one plot per row showing all the data for each geography, although this can be changed by specifyingby="acs.colnames"
, to plot each variable as its own plot, with all of the geographies along the x-axis.In the special case where the dimensions of the object are exactly c(1,1) (i.e., a single geography and column),
plot
will return a density plot of the estimate. In this case,conf.level
,err.col
,err.lty
, anderr.lwd
will be used to determine the properties of the margins of error lines. (For none, useconf.level=F
. For these density plots, users may also wish to setxlim
andx.res
, which specify the horizontal extent and resolution of the plot.)plot
accepts many of the standard graphical arguments toplot
, such asmain
,sub
,xlab
,pch
, andcol
, as well new ones listed above.In some cases, the lower bound of a confidence interval may extend below 0; in some cases this is desired, especially when a variable is actually stating the difference between two estimates. In other cases, this may seem confusing (for example, when reporting the estimated count in a particular category). Setting
true.min
toFALSE
(or 0) will limit the lower boundary of any confidence intervals computed and plotted.
Examples
# load ACS data
data(kansas07)
# plot a single value
plot(kansas07[4,4])
# plot by geography
plot(kansas07[,10])
# plot by columns
plot(kansas07[4,3:10])
# a density plot for a single variable
plot(kansas07[7,10])
# same, using some graphical parameters
plot(kansas07[7,10], col="blue", err.col="purple", err.lty=3)
plot(kansas07[7,49], col="lightblue", type="h", x.res=3000,
err.col="purple", err.lty=3, err.lwd=4, conf.level=.99,
main=(paste("Distribution of Females>85 Years in ",
geography(kansas07)[7,1], sep="")),
sub="(99-percent margin of error shown in purple)")
# something more complicated...
plot(kansas07[c(1,3,4),3:25], err.col="purple",
pch=16, err.pch="x", err.cex=1, ylim=c(0,5000),
col=rainbow(23), conf.level=.99,
labels=paste("grp. ",1:23))