Learn R Programming

oaPlots (version 0.0.25)

drawSplitDensity: Draw a Split Density Plot

Description

Draw a Split Density Plot

Usage

drawSplitDensity(x = NULL, y = NULL, densityObj = NULL, yshift = 0, colVec, outerCol, lwd = 2, split = NULL, yScale = NULL, fillBackground = FALSE)

Arguments

x
x vector from a density object. e.g. data <- rnorm(100); x <- density(data)$x
y
y vector from a density object
densityObj
an object created by the function density()
yshift
vertical shift to be applied to the y object
colVec
color vector for the shaded regions that compose the interior of the plot. The length of 'colVec' should be one greater than the length of split
outerCol
the color for the outer density line
lwd
line width for the outer density line
split
vector of x values at which to split the density plot
yScale
vertical scale at which to plot the density. For example, a call with 'yScale = 1' will produce a density curve scaled between 0 and 1
fillBackground
binary specification of whether to fill in the background the outerCol color

Value

none. Graph is plotted to the current device

Examples

Run this code
library(RColorBrewer)
data <- rnorm(1000)
x <- density(data)$x
y <- density(data)$y
colVec <- brewer.pal(9, "Blues")[3:8]
outerCol <- brewer.pal(9, "Blues")[9]

oaTemplate(xlim = range(x), ylim = c(0, 1), ygrid = 0, cex.axis = 1.2)
drawSplitDensity(x, y, colVec = colVec, split = c(-8),
		outerCol = outerCol,
		yScale = 0.95, yshift = 0)

Run the code above in your browser using DataLab