plot_density_contours: Produce a 2D density/histogram plot given data values 'x, y'.

Description Usage Arguments Details Value See Also Examples

View source: R/plot_contour.R

Description

plot_density_contours generates a 2D density/histogram plot.

Usage

1
2
3
4
5
plot_density_contours(x, y, xlim, ylim, npix = 25,
  prob.levels = c(0.683, 0.9), plot.dots = TRUE,
  plot.contours = TRUE, plot.image = FALSE, dot.level = NULL,
  jittr = FALSE, col = "black", pch = 1, cex = 1,
  smooth2d = TRUE, xlab = "", ylab = "", ...)

Arguments

x, y

(vectors) x and y data values (equal length vectors).

xlim, ylim

(vectors) The (x, y) limits of the axes (x1, x2), (y1, y2).

npix

(integer) use npix*npix grid of pixels for computing 2D smoothed distributions (resolution of contour maps)

prob.levels

(float) probability levels, e.g. to plot contours enclosing 90% and 95% of the mass on 2D distributions

plot.dots

(logical) Plot points outside of outer contour?

plot.contours

(logical) Plot the contours?

plot.image

(logical) Plot a colour image underneath the contours?

dot.level

(integer) draw dots outside of which contour? (1,2,...)

jittr

(logical) add 'jitter' to points to reduce overlap.

col

(string) colour of the data points.

pch

(integer) Plotting 'character', i.e. symbol to use. Same as 'base' graphics.

cex

(float) character expansion factor.

smooth2d

(logical) use smooth, kernel density estimates, rather than 2D histograms?

xlab, ylab

(strings) Labels for x, y axes.

...

(anything) any other graphical keywords to be passed to plot(...)

Details

Given vectors x, y specifying the coordinates of data points, plot_density_contours generates a 2D density plot. What is plotted are contours enclosing specified masses of the distribution, and points outside of the outermost contour are marked individually. The contours are based on either a smooth 2D kernel estimate or an a (rough) 2D histogram.

Value

None.

See Also

chain_convergence, contour_matrix

Examples

1
2
3
4
5
6
n <- 1000
x <- rnorm(n)
y <- x + rnorm(n)
img <- hist2d(x, y, npix = 40)
plot_density_contours(x,y, xlim = c(-4, 4), ylim = c(-4, 4))
axis(1); axis(2)

svdataman/tonic documentation built on Aug. 2, 2019, 3:21 p.m.