dotPlot {openintro}R Documentation

Dot plot

Description

Plot observations as dots.

Usage

dotPlot(x, fact = NULL, vertical = FALSE, at = 1, key = NULL, pch = 20, col = fadeColor("black", "66"), cex = 1.5, add = FALSE, axes = TRUE, xlim = NULL, ylim = NULL, ...)

Arguments

x A numerical vector.
fact A character or factor vector defining the grouping for data in x.
vertical If TRUE, the plot will be oriented vertically.
at The vertical coordinate of the points, or the horizontal coordinate if vertical=TRUE. If fact is provided, then locations can be specified for each group.
key The factor levels corresponding to at, pch, col, and cex.
pch Plotting character. If fact is given, then different plotting characters can be specified for each factor level. If key is specified, the elements of pch will correspond to the elements of key.
col Plotting character color. If fact is given, then different colors can be specified for each factor level. If key is specified, the elements of col will correspond to the elements of key.
cex Plotting character size. If fact is given, then different character sizes can be specified for each factor level. If key is specified, the elements of cex will correspond to the elements of key.
add If TRUE, then the points are added to the plot.
axes If FALSE, no axes are plotted.
xlim Limits for the x axis.
ylim Limits for the y axis.
... Additional arguments to be passed to plot if add=FALSE or points if add=TRUE.

Author(s)

David Diez

See Also

histPlot, densityPlot, boxPlot

Examples

#===> example 1 <===#
data(cars)
dotPlot(cars$price, cars$type, key=c('large', 'midsize', 'small'), cex=1:3)

#===> example 2 <===#
data(run10)
layout(matrix(1:2,2), heights=c(2.7,1.5))
par(las=1)
dotPlot(run10$time[run10$gender=='M'], run10$div[run10$gender=='M'], col=fadeColor('black', '11'))
# disorganized levels in the above plot, which we could
# organize with key. an example of organizing the levels...
dotPlot(run10$time[run10$gender=='M'], run10$div[run10$gender=='M'], col=fadeColor('black', '11'), key=c('20-24', '25-29', '30-34', '35-39')) # just looking at male runners who are 20 to 39
par(las=0, mfrow=c(1,1))

#===> example 3 <===#
data(marioKart)
dotPlot(marioKart$totalPr, marioKart$cond, ylim=c(0.5,2.5), xlim=c(25, 80), cex=1) # the ylim is low enough that we do not observe the outliers
boxPlot(marioKart$totalPr, marioKart$cond, add=1:2+0.1, key=c('new', 'used'), horiz=TRUE, axes=FALSE)

[Package openintro version 1.0 Index]