Learn R Programming

lattice (version 0.22-5)

F_2_panel.smoothScatter: Lattice panel function analogous to smoothScatter

Description

This function allows the user to place smoothScatter plots in lattice graphics.

Usage

panel.smoothScatter(x, y = NULL,
                    nbin = 64, cuts = 255,
                    bandwidth,
                    col.regions,
                    colramp,
                    nrpoints = 100,
                    transformation = function(x) x^0.25,
                    pch = ".",
                    cex = 1, col="black",
                    range.x,
                    ...,
                    raster = FALSE,
                    subscripts,
                    identifier = "smoothScatter")

Value

The function is called for its side effects, namely the production of the appropriate plots on a graphics device.

Arguments

x

Numeric vector containing x-values or n by 2 matrix containing x and y values.

y

Numeric vector containing y-values (optional). The length of x must be the same as that of y.

nbin

Numeric vector of length 1 (for both directions) or 2 (for x and y separately) containing the number of equally spaced grid points for the density estimation.

cuts

number of cuts defining the color gradient

bandwidth

Numeric vector: the smoothing bandwidth. If missing, these functions come up with a more or less useful guess. This parameter then gets passed on to the function bkde2D.

col.regions

character vector of colors, or a function producing such a vector. Defaults to the col component of the regions setting of the current theme.

colramp

Function accepting an integer n as an argument and returning n colors. If missing, the default is derived from col.regions with the following modification: if col.regions is a vector of colors, it is prepended by "white" before being converted into a function using colorRampPalette.

nrpoints

Numeric vector of length 1 giving number of points to be superimposed on the density image. The first nrpoints points from those areas of lowest regional densities will be plotted. Adding points to the plot allows for the identification of outliers. If all points are to be plotted, choose nrpoints = Inf.

transformation

Function that maps the density scale to the color scale.

pch, cex

graphical parameters for the nrpoints “outlying” points shown in the display

range.x

see bkde2D for details.

col

points color parameter

...

Further arguments that are passed on to panel.levelplot.

raster

logical; if TRUE, panel.levelplot.raster is used, making potentially smaller output files.

subscripts

ignored, but necessary for handling of ... in certain situations. Likely to be removed in future.

identifier

A character string that is prepended to the names of grobs that are created by this panel function.

Author

Deepayan Sarkar deepayan.sarkar@r-project.org

Details

This replicates the display part of the smoothScatter function by replacing standard graphics calls by grid-compatible ones.

Examples

Run this code

ddf <- as.data.frame(matrix(rnorm(40000), ncol = 4) + 1.5 * rnorm(10000))
ddf[, c(2,4)] <- (-ddf[, c(2,4)])
xyplot(V1 ~ V2 + V3, ddf, outer = TRUE,
       panel = panel.smoothScatter, aspect = "iso")
## argument to panel.levelplot
xyplot(V1 ~ V2, ddf, panel = panel.smoothScatter, cuts = 10,
       region.type = "contour")
splom(ddf, panel = panel.smoothScatter, nbin = 64, raster = TRUE)

Run the code above in your browser using DataLab