Displays numeric estimates as points on a horizontal scale. Optional confidence limits are shown as horizontal lines with capped endpoints. Several series of estimates can be arranged in labelled groups.
Usage
plotDot(
x,
main = NULL,
xlim = NULL,
xax = NULL,
yax = NULL,
axes = TRUE,
items = NULL,
groups = NULL,
gap = 1,
pch = .useTheme,
cex = .useTheme,
grid = .useTheme,
box = .useTheme,
stamp = .useTheme,
...
)Arguments
- x
numeric estimates or confidence interval data. Supported formats are a numeric vector, a numeric matrix, a three-dimensional numeric array, or a
"CI"object created withas.CI()- main
main title.
NULL(default) draws none."",NAorFALSEalso suppress it; the top margin is compacted whenever no title is drawn.- xlim
numeric vector containing the limits of the horizontal axis; by default, the range of all estimates and confidence limits
- xax
controls the x-axis.
NULL(default) orTRUEdraws it with default settings,FALSEsuppresses it. A string is taken as the format of the tick labels,xax = "%"is short forxax = list(fmt = "%"). A named list may mix arguments forfm()(fmt,digits,bigMark, ...) and forgraphics::axis()(las,col,cex, ...).- yax
controls the item axis (y-axis).
NULL(default) orTRUEdraws it with default settings,FALSEsuppresses it (the group headers are still drawn). A named list is passed tographics::axis(), e.g.tick,las,col.axis,line,hadj;fontandcexare short forfont.axisandcex.axis.labelsreplaces the item labels, either one per item (repeated in every group) or one per point;labels = FALSEdraws the ticks only.sideandatare fixed by the layout.col.axis,font.axisandcex.axismay be vectors, recycled likelabels: one value per item repeats in every group, one per point sets every label.- axes
logical; whether the horizontal and item axes are drawn.
FALSEoverridesxaxandyax- items
optional character vector containing the item labels; defaults to the row names or first dimension names of
x- groups
controls the group headers. A character vector gives the labels; by default the column names or third dimension names of
x.FALSEsuppresses the headers (the layout keeps their rows). A named list setslabelsand arguments forgraphics::text(), e.g.col,font(default 2),cex(defaultpar("cex.axis")),adj;col,fontandcexmay be vectors with one value per group. Headers are drawn only for two or more groups.- gap
non-negative number, the vertical space between groups in item rows
- pch
specification for the estimate points. The default
.useThemeuses the point settings of the active theme. A plotting symbol or a named list containing parameters such aspch,col,bg, andcexcan also be supplied, plusby, which decides whether vectors are recycled over the groups ("group", default) or over the items ("item"); see Details- cex
character expansion factor for the points.
.useTheme(default) resolves togetTheme()$points$cex.- grid
specification controlling the horizontal item and group grid lines. The default
.useThemefollows the active theme. A logical value,NA, or a named list of graphical parameters can also be supplied- box
specification controlling the plot box. The default
.useThemeuses the active theme. A logical value,NA, or a named list of graphical parameters can also be supplied- stamp
controls the corner stamp.
.useTheme(default) resolves togetTheme()$stamp.TRUE/FALSE/NULL, a string, or a named list forstamp().- ...
additional graphical parameters passed to
graphics::par(). Amarthat sets the left side switches off the automatic widening of the left margin for the labels.
Value
invisibly, a list containing:
yposvertical positions of the items within each group, a list in the order of the groups
group_yvertical positions of the group labels
sep_yvertical positions of the group separators
Details
A numeric vector represents one estimate for each item; a
one-dimensional table or array, such as the result of tapply() with
one grouping factor, is treated the same way.
A numeric matrix represents estimates only: rows define the items and columns define the groups. Consequently, a matrix with three columns is interpreted as three groups and not automatically as estimates with lower and upper confidence limits.
Use as.CI() to declare explicitly that a matrix, data frame,
list, or result from tapply() contains confidence interval
data:
A "CI" object contains the columns est, lci, and
uci. Additional columns can define the item and group structure.
If two additional columns are present, the first defines the items and the
second defines the groups.
Confidence interval data can alternatively be supplied as a
three-dimensional numeric array with dimensions
items × 3 × groups. The second dimension must contain, in this
order, the estimate, lower confidence limit, and upper confidence limit.
Values supplied directly as arguments take precedence over the
corresponding settings of the active theme. Vectors in pch (e.g.
pch = list(col = c("red", "blue"))) are recycled over the groups, in
the order in which the groups are drawn from top to bottom. With
by = "item" they are recycled over the items instead, so that each
item keeps its colour in every group, e.g. one colour per population
within age groups. A matrix with one row per item and one column per
group sets every point individually. The confidence lines take the
colour of their point.
See also
as.CI(), isCI(),
graphics::dotchart()
Other plot.univariate:
plotArea(),
plotBar(),
plotBox(),
plotCatDist(),
plotDens(),
plotDensBox(),
plotECDF(),
plotFreqDist(),
plotLines(),
plotQQ(),
plotRidge(),
plotViolin()
Examples
# estimates for a single series
est <- c(A = 12, B = 18, C = 28, D = 40, E = 65)
plotDot(
est,
main = "Estimates"
)
# matrix columns represent groups of estimates
groupedEst <- cbind(
Control = c(A = 12, B = 18, C = 28),
Treatment = c(A = 16, B = 24, C = 35)
)
plotDot(
groupedEst,
main = "Grouped estimates"
)
# confidence intervals stored in a matrix
ci <- cbind(
est = est,
lci = est - c(2, 3, 4, 5, 6),
uci = est + c(2, 3, 4, 5, 6)
)
plotDot(
as.CI(ci),
main = "Estimates with confidence intervals"
)
# grouped confidence intervals stored in a data frame
groupedCI <- data.frame(
item = rep(c("A", "B", "C"), 2),
group = rep(c("Control", "Treatment"), each = 3),
estimate = c(12, 18, 28, 16, 24, 35),
lower = c(10, 15, 24, 13, 20, 30),
upper = c(14, 21, 32, 19, 28, 40)
)
plotDot(
as.CI(
groupedCI,
estimate = "estimate",
lower = "lower",
upper = "upper"
),
main = "Grouped confidence intervals"
)
# colours per item: every group shows the items in the same colours
plotDot(
t(groupedEst),
pch = list(pch = 21, by = "item",
col = c("steelblue4", "darkorange3"),
bg = c("steelblue1", "orange")),
main = "Colours per item"
)
# item axis without ticks, labels in regular font and grey
plotDot(
groupedEst,
yax = list(tick = FALSE, font = 1, col.axis = "grey30"),
main = "Item axis without ticks"
)
# returned positions can be used to add graphical elements
pos <- plotDot(est)
points(
est + 3,
y = unlist(pos$ypos),
pch = 4
)
