Learn R Programming

rv (version 2.3.1)

points.rv: Add Points and Intervals to a Plot

Description

Draw a sequence of points or uncertainty intervals at specified (fixed) x-coordinates.

Usage

"points"(x, y = NULL, type = "p", xlim = NULL, ylim = NULL, rvlwd = rvpar("rvlwd"), rvcol = rvpar("rvcol"), rvpoint = rvpar("rvpoint"), rvlex = rvpar("rvlex"), ...)

Arguments

x
x-coordinates
y
y-coordinates
type
character indicating the type of plotting
rvcol
colors for the intervals
xlim
x-limits (optional)
ylim
y-limits (optional)
rvlwd
line width of the thin interval
rvpoint
character vector of length 3, indicating intervals (points) to print
rvlex
factor to multiply rvlwd with, to get the thicker interval
...
further arguments passed to points

Details

Each 'point' with a fixed coordinate and a random coordinate is plotted as an interval. If "lines" are plotted (type="l" or type="b"), the result is a random draw of lines connecting the coordinates. See lines.rv for details on how to set the sample size of the random draw.

Each interval consists of a maximum of three components. (1) a dot (2) thick interval (3) thin interval. Typically the dot marks the mean or the median; the thin and the thick intervals show a shorter and a longer middle uncertainty interval. The appearance of these intervals can be controlled using the parameters rvlwd, rvpoint, rvcol, and rvlex.

rvlwd sets the line width of the thin interval; rvlex sets the factor to multiply rvlwd to get the line width of the thicker interval.

points attempts to color the intervals and the dot using the color given as rvcol. The basic name of the color should be given, e.g. "red" or "blue". The thin line is colored using the basic color, the thick line is colored using a darker hue (numbered '2', e.g. "red2") and the dot is colored using the darkest hue (numbered '3', e.g. "red3"). That is, for example. if rvcol='red', the color scheme generated for the dot, the thick line, and the thin line, respectively, are c('red3', 'red2', 'red').

Special color themes: the default rvcol color scheme is called "default" and yields the color scheme c("grey20", "grey40", "grey60"). Other special color themes: "grey", "lightgrey", "darkgrey". (The spellings 'gray' and 'grey' are interchangeable).

The parameter rvpoint is a character vector of length 3, with the first component indicating what to plot as a dot (possible values: "mean", "median"), the second component indicating what to plot as a "thick interval" (possible values: "n the second component indicating what to plot as a "thin interval". Default: c("mean", "50%", "95%"). If you wish only to plot the mean and the 95% interval, use rvpoint=c("mean", NA, "95%") or rvpoint=c("mean", "95%", NA).

The color col is used for plotting fully fixed dots (both x and y coordinates fixed) and lines (fixed and random lines -- see lines.rv).

NOTE. This parameterization is yet experimental, and may change.

It is possible to have both x and y random, but this code is not yet fully functional.

References

Kerman, J. and Gelman, A. (2007). Manipulating and Summarizing Posterior Simulations Using Random Variable Objects. Statistics and Computing 17:3, 235-244.

See also vignette("rv").

Examples

Run this code
  x <- as.rv(1:10)
  y <- rvnorm(mean=x)
  par(mfrow=c(2,2))
  plot(x, y, main="Fixed x-coordinate")
  plot(y, x, main="Fixed y-coordinate")
  plot(x, y, lwd=4, rvcol="red", main="Color and line width changed")
  plot(x, y, type="b", main="Intervals and random lines", rvcol="blue", col="gray")
  ## Not run: 
#     # Don't use the rv-only parameters when plotting fixed vectors.
#     plot(x, E(y), rvcol="blue", col="gray")
#     plot(x, E(y), rvcol="blue", col="gray")
#   ## End(Not run)

Run the code above in your browser using DataLab