Description Usage Arguments See Also Examples
Add a marginal histogram to a plot.
1 2 3 4 5 6 7 8 9 10 11 |
x |
A numeric vector, the first set of data to be binned into a histogram. |
y |
A numeric vector, the second set of data to be binned into a histogram, default NULL. |
type |
A character scalar, indicating to which plot axes histograms should be
added; |
nclass |
An integer scalar, the target number of bins for the histogram, default 20. |
newmar |
A numeric vector of length 2, indicating new margins to use, default c(0, 1). |
adj.fac |
A numeric scalar, adjustment factor for extent of y-axis, default 1.05 (to ensure tallest bars in histogram are below axis box). |
xlab |
A character scalar, label for x-axis, default "Frequency". |
ylab |
A character scalar, label for y-axis, default "". |
fill |
A character or numeric scalar, color for filling in histogram bars, default "gray". |
hist
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # fake data
xx <- rnorm(30)
yy <- runif(30)
# type "x"
layout(matrix(2:1, ncol=1), heights=c(1/5, 4/5))
par(mar=c(4, 4, 0, 1), cex=1, las=1)
plot(xx, yy)
addhist(xx, type="x")
# type "y"
layout(matrix(1:2, ncol=2), widths=c(4/5, 1/5))
par(mar=c(4, 4, 1, 0), cex=1, las=1)
plot(xx, yy)
addhist(yy, type="y")
# type "xy"
layout(matrix(c(2, 1, 0, 3), ncol=2),
heights=c(1/5, 4/5), widths=c(4/5, 1/5))
par(mar=c(4, 4, 0, 0), cex=1, las=1)
plot(xx, yy)
usr <- par("usr")
mar <- par("mar")
addhist(xx, yy, type="xy")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.