squashgram {squash} | R Documentation |
Visualize a function of z coordinates, binned by x, y coordinates
Description
This is a convenience function combining matapply
and colorgram
. 3-dimensional data is summarized in 2-dimensional bins and represented as a color matrix. Optionally, the number of observations in each bin is indicated by relative size of the matrix elements.
Usage
squashgram(x, y = NULL, z = NULL, FUN,
nx = 50, ny = nx, xlim = NULL, ylim = NULL,
xbreaks = NULL, ybreaks = NULL,
xlab = NULL, ylab = NULL, zlab = NULL,
shrink = 0, ...)
Arguments
x , y , z |
Numeric vectors; see Details. |
FUN |
Function to summarize z values. |
nx , ny |
Approximate number of bins along x and y axis. |
xlim , ylim |
Limit the range of data points considered. |
xbreaks , ybreaks |
Breakpoints between bins along x and y axes. |
xlab , ylab |
Axis labels. |
zlab |
Label for color key. |
shrink |
Rectangle shrinkage cutoff. |
... |
Further arguments passed to |
Details
This function may be useful for visualizing the dependence of a variable (z
) on two other variables (x
and y
).
x
, y
and z
values can be passed to squash
in any form recognized by xyz.coords
(e.g. individual vectors, list, data frame, formula).
This function calls matapply
and plots the result along with a color key.
If non-zero, the shrink
parameter reduces the size of rectangles for
the bins in which the number of samples is smaller than shrink
. This may be useful to reduce the visual impact of less reliable observations.
Value
None.
See Also
The lower-level functions matapply
and colorgram
.
Examples
## earthquake depths in Fiji
attach(quakes)
squashgram(depth ~ long + lat, FUN = mean)
## iris measurements
attach(iris)
squashgram(Sepal.Length, Sepal.Width, Petal.Length,
FUN = median, nx = 20, ny = 15)
## Here indicate sample size by size of rectangles
squashgram(iris[,1:3], FUN = median,
nx = 20, ny = 15, shrink = 5)
## What is the trend in my noisy 3-dimensional data?
set.seed(123)
x <- rnorm(10000)
y <- rnorm(10000)
z <- rnorm(10000) + cos(x) + abs(y / 4)
squashgram(x, y, z, median, colFn = bluered, shrink = 5)