dsplot | R Documentation |
This creates a scatter plot (sort of) for discrete, bivariate data; an alternative to sunflower plots for integer-valued variables.
dsplot(x, ...)
## Default S3 method:
dsplot(
x,
y,
...,
bg.col = TRUE,
col = par("col"),
xlab = NULL,
ylab = NULL,
pch = par("pch"),
cex = par("cex")
)
## S3 method for class 'formula'
dsplot(formula, data = NULL, ..., subset, na.action = NULL)
x, y |
x- and y-axis variables |
... |
for the for the default method, unnamed arguments are additional data vectors
(unless x is a list when they are ignored), and named arguments are
arguments and |
bg.col |
logical or color name to fill boxes with based on density; if
|
col |
plotting color |
xlab, ylab |
x- and y-axis labels |
pch |
plotting character |
cex |
numerical value giving the amount by which plotting text and
symbols should be magnified relative to the default; this starts as 1
when a device is opened and is reset when the layout is changed, e.g.,
by setting |
formula |
a |
data |
a data frame (or list) from which the variables in formula should be taken |
subset |
an optional vector specifying a subset of observations to be used for plotting |
na.action |
a function which indicates what should happen when the data
contain |
A table (invisibly) corresponding to the plot cell counts.
set.seed(1)
x <- round(rnorm(400, 100, 4))
y <- round(rnorm(400, 200, 4))
sex <- sample(c('Female', 'Male'), 400, replace = TRUE)
dsplot(x, y, col = (sex %in% 'Female') + 1L, bg.col = FALSE)
dsplot(x, y, col = (sex %in% 'Female') + 1L, bg.col = 'tomato')
dsplot(y ~ x, pch = 19, col = (sex %in% 'Female') + 1L,
cex = 0.6, bty = 'l', bg.col = 'tomato',
xlab = 'measurement 1', ylab = 'measurement 2')
legend('bottomright', pch = 19, col = 1:2, bty = 'n',
legend = c('Male', 'Female'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.