shipunov (version 1.5)

Dotcharts: Improved dotcharts

Description

Dotcharts, improved and extended

Usage

Dotchart1(x, labels = NULL, groups = NULL, gdata=NULL,
 ann=par("ann"), xaxt=par("xaxt"), frame.plot=TRUE, log="",
 cex=par("cex"), pt.cex=cex, pch=21, gpch=21, bg=par("bg"),
 color=par("fg"), gcolor=par("fg"), lcolor= "gray",
 xlim=range(x[is.finite(x)]), main= NULL, xlab=NULL,
 ylab=NULL, ...)

Dotchart(...)

Dotchart3(values, left, right, pch=21, bg="white", pt.cex=1.2, lty=1, lwd=2, gridcol="grey", ...)

Arguments

x

Either a vector or matrix of numeric values. Inputs are coerced by 'as.numeric()', with a message.

labels

A vector of labels for each point.

groups

An optional factor indicating how the elements of 'x' are grouped.

gdata

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

ann

Logical value indicating whether title and x and y axis labels should appear on the plot.

xaxt

String indicating the x-axis style; use 'n' to suppress and see also par("xaxt").

frame.plot

Logical indicating whether a box should be drawn around the plot.

log

Character string indicating if one or the other axis should be logarithmic, see ?plot.default.

cex

The character size to be used.

pt.cex

The 'cex' to be applied to plotting symbols.

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.

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.

main

Overall title for the plot, see 'title'.

xlab, ylab

Axis annotations as in 'title'.

values

Centers for 'Dotchart3()'

left

Left margins for 'Dotchart3()'

right

Right margins for 'Dotchart3()'

lty

Line type for 'Dotchart3()'

lwd

Line width for 'Dotchart3()'

gridcol

Grid color for 'Dotchart3()'

...

Additional arguments

Details

For better explanations of options, see 'help(dotchart)'.

'Dotchart1()' is a default 'dotchart()' corrected for use with 1-dimensional tables with 'ylab' and/or changed 'par("mar")[2]'. So comparing with the default 'dotchart()', it has a better left margin. It also outputs message instead of warning.

'Dotchart()' is a prettified 'Dotchart1()' with the following defaults: 'Dotchart1(lcolor="black", bg="white", pt.cex=1.2, ...)'. Use it as a shortcut.

'Dotchart3()' shows values together with ranges. It is an extension of 'Dotchart1()'; for each value, it shows ranges. Does not work with grouped data. A bit similar to 'Linechart()' but more general.

See Also

dotchart, Linechart

Examples

Run this code
# NOT RUN {
## Compare:
aa <- table(c(1, 1, 1, 2, 2, 3))
##
Dotchart1(aa, ylab="Ylab") # shows 'ylab'; outputs message instead of warning
dotchart(aa, ylab="Ylab") # does not show 'ylab'; produces warning
##
## changes all margins (note: Dotchart1() cannot forcedly _decrease_ left margin)
old.par <- par(mar=c(1, 10, 1, 1)) ; Dotchart1(aa, ylab="Ylab") ; par(old.par)
## does not change left margin
old.par <- par(mar=c(1, 10, 1, 1)) ; dotchart(aa, ylab="Ylab") ; par(old.par)

Dotchart(aa)

Dotchart3(structure(1:3, names=LETTERS[1:3]), 0:2, 2:4)
Dotchart3(structure(0:2, names=LETTERS[1:3]), 0:2, 2:4, pch="") # ranges only
# }

Run the code above in your browser using DataCamp Workspace