Sectioned density plots
Description
Sectioned density plots (Cohen and Cohen, 2006) use shading and occlusion to give a compact illustration of a distribution, such as the empirical distribution of data.
Usage
1 2 3 4 5 
Arguments
x 
Either the vector of points at which the density is
evaluated (if 
dens 
Density at 
at 
Position of the bottom of the plot on the yaxis (if

ny 
Number of fixedwidth intervals for categorising the density. 
width 
Width of individual rectangles in the plot. Defaults to the range of the axis divided by 20. 
offset 
Offset for adjacent rectangles. Defaults to

method 
Method of estimating the density of If If 
nx 
Number of data bins for the 
horiz 
If 
up.left 
If changed to 
colmax 
Darkest colour, either as a builtin R colour name (one
of 
colmin 
Lightest colour, either as a builtin R colour name (one
of 
gamma 
Gamma correction to apply to the colour palette, see 
lattice 
Set this to 
... 
Additional arguments supplied to 
Author(s)
Christopher Jackson <chris.jackson@mrcbsu.cam.ac.uk> (R implementation)
References
Cohen, D. J. and Cohen, J. The sectioned density plot. The American Statistician (2006) 60(2):167–174
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25  ## Fisher's iris data
## Various settings to change the look of the plot
hist(iris$Sepal.Length, nclass=20, col="lightgray")
sectioned.density(iris$Sepal.Length, at=0.2)
sectioned.density(iris$Sepal.Length, at=5)
sectioned.density(iris$Sepal.Length, at=10, width=0.5)
hist(iris$Sepal.Length, nclass=20, col="lightgray")
sectioned.density(iris$Sepal.Length, at=7, width=0.5,
offset=0.1, colmax="darkmagenta")
sectioned.density(iris$Sepal.Length, at=9, width=0.5,
offset=0.1, ny=15, colmin="lemonchiffon")
## frequency method less smooth than kernel density
sectioned.density(iris$Sepal.Length, at=12, width=0.5, offset=0.1,
method="frequency")
sectioned.density(iris$Sepal.Length, at=13.5, width=0.5, offset=0.1,
method="frequency", nx=20)
## Illustrate a known distribution
x < seq(4, 4, length=1000)
dens < dnorm(x)
plot(x, xlim=c(5, 5), ylim=c(5, 5), xlab="x", ylab="x", type="n")
sectioned.density(x, dens, ny=8, at=0, width=0.3)
sectioned.density(x, dens, ny=16, at=2, width=0.1)
sectioned.density(x, dens, at=3, horiz=FALSE)
sectioned.density(x, dens, at=4, width=0.3, horiz=FALSE)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.