Learn R Programming

plotfunctions (version 1.4)

dotplot_error: Utility function

Description

Adjusted version of the a Cleveland dot plot implemented in dotchart with the option to add confidence intervals.

Usage

dotplot_error(
  x,
  se.val = NULL,
  labels = NULL,
  groups = NULL,
  gdata = NULL,
  cex = par("cex"),
  pch = 21,
  gpch = 21,
  bg = "black",
  color = par("fg"),
  gcolor = par("fg"),
  lcolor = "gray",
  xlim = NULL,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  lwd = 1,
  ...
)

Arguments

x

either a vector or matrix of numeric values (NAs are allowed). If x is a matrix the overall plot consists of juxtaposed dotplots for each row. Inputs which satisfy is.numeric(x) but not is.vector(x) || is.matrix( x) are coerced by as.numeric, with a warning.

se.val

a vector or matrix of numeric values representing the standard error or confidence bands.

labels

a vector of labels for each point. For vectors the default is to use names(x) and for matrices the row labels dimnames(x)[[1]].

groups

an optional factor indicating how the elements of x are grouped. If x is a matrix, groups will default to the columns of x.

gdata

data values for the groups. This is typically a summary such as the median or mean of each group.

cex

the character size to be used. Setting cex to a value smaller than one can be a useful way of avoiding label overlap. Unlike many other graphics functions, this sets the actual size, not a multiple of par('cex').

pch

the plotting character or symbol to be used.

gpch

the plotting character or symbol to be used for group values.

bg

the background color of plotting characters or symbols to be used; use par(bg= *) to set the background color of the whole plot.

color

the color(s) to be used for points and labels.

gcolor

the single color to be used for group labels and values.

lcolor

the color(s) to be used for the horizontal lines.

xlim

horizontal range for the plot, see plot.window, e.g.

main

overall title for the plot, see title.

xlab

x-axis annotation as in title.

ylab

y-axis annotation as in title.

lwd

with of error bars.

...

graphical parameters can also be specified as arguments see par

See Also

dotchart

Other Functions for plotting: addInterval(), add_bars(), add_n_points(), alphaPalette(), alpha(), check_normaldist(), color_contour(), drawDevArrows(), emptyPlot(), errorBars(), fill_area(), getCoords(), getFigCoords(), getProps(), gradientLegend(), legend_margin(), marginDensityPlot(), plot_error(), plot_image(), plotsurface(), sortBoxplot()

Examples

Run this code
# NOT RUN {
# example InsectSprays from R datasets
avg <- aggregate(count ~ spray, data=InsectSprays, mean)
avg <- merge(avg, 
    aggregate(count ~ spray, data=InsectSprays, sd),
    by='spray', all=TRUE)

dotplot_error(avg$count.x, se.val=avg$count.y, labels=avg$spray)

# we could add the type of spray to the averages:
avg$type <- c(1,1,2,2,2,1)
dotplot_error(avg$count.x, se.val=avg$count.y, groups=avg$type, labels=avg$spray) 

# }

Run the code above in your browser using DataLab