sqbin | R Documentation |
The sqbin
function calculates frequencies in xy bins
sqbin(x, y, xint = NULL, yint = NULL, nxbin = 50, nybin = 50)
x |
a vector of x values |
y |
a vector of y values |
xint |
a vector of x intervals (end values). Defaults to values as specified
by |
yint |
a vector of y intervals (end values). Defaults to values as specified
by |
nxbin |
number of x bins. Default=50. Not used when |
nybin |
number of y bins. Default=50. Not used when |
A matrix containing interval mid points (x,y
), bin frequencies (z
),
and intervals (xint, yint
).
# Synthetic data
set.seed(1)
n <- 1e6
x <- runif(n, min=-3, max=3)
y <- 4*x^2 + rnorm(n, sd=5)
sqbin.res <- sqbin(x,y)
# Plot
op <- par(mar=c(4,4,1,1))
image(sqbin.res, col=jetPal(20))
par(op)
# Plot with legend
op <- par(no.readonly = TRUE)
lo <- matrix(1:2, nrow=1, ncol=2)
layout(lo, widths=c(4,1), heights=c(4), respect=TRUE)
par(cex=1)
par(mar=c(3,3,1,1))
image(sqbin.res, col=jetPal(20))
par(mar=c(3,0,1,3))
imageScale(sqbin.res$z, col=jetPal(20), axis.pos=4)
par(op)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.