scattergram | R Documentation |
A scattergram plot with density curves along axes.
scattergram(
x,
y,
g = NULL,
col = NULL,
...,
add = FALSE,
xlim = NULL,
ylim = NULL,
axs = "i",
heights = 0.25,
main = NULL,
legend = TRUE,
args.legend = list()
)
x, y, g |
the x-, y-, and group variables |
col |
a vector of colors or integers for each unique value of |
... |
additional arguments passed to |
add |
logical; if |
xlim, ylim |
the x- and y-axis limits |
axs |
the style(s) of axis interval calculation; see |
heights |
for |
main |
the main figure title |
legend |
logical; if |
args.legend |
a named list of |
with(mtcars, {
scattergram(mpg, wt)
})
with(mtcars, {
scattergram(mpg, wt, cyl, col = rainbow(3), pch = 16)
})
with(mtcars, {
scattergram(
mpg, wt, c('Four', 'Six', 'Eight')[cyl / 2 - 1],
xlab = 'MPG', ylab = 'Weight', las = 1,
panel.first = abline(lm(wt ~ mpg), col = 5, lwd = 3),
panel.last = abline(v = c(20, 25))
)
})
## to add multiple figures on a plot, use add = TRUE
sp <- split(mtcars, mtcars$am)
op <- par(mfrow = 1:2, mar = c(5, 5, 5, 4), oma = c(0, 0, 0, 2))
lapply(sp, function(d) {
scattergram(d$mpg, d$wt, d$cyl, col = 1:3, add = TRUE)
})
par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.