multidensity: Plot multiple kernel density estimates

Description Usage Arguments Value See Also Examples

View source: R/multidensity.R

Description

Plot multiple kernel density estimates in the same window, together with a legend

Usage

1
2
3
4
5
6
multidensity(x, main, xlab = "", ylab = "Density", xlim, ylim,
  col = 1:9, lty = 1:2, lwd = 1, add = FALSE, frame.plot = TRUE,
  legend = TRUE, x.legend = "topleft", y.legend = NULL, bty = "o",
  box.col = "#FFFFFF00", bg.legend = "#FFFFFFAA", cex.legend = 0.7,
  x.intersp = 1, y.intersp = 1.5, inset = 0, xpd.legend = NA,
  horiz = FALSE, ...)

Arguments

x

a list or data.frame of numeric values

main

a main title for the plot. Defaults to the call made to density

xlab, ylab

labels for the x and y axes

xlim, ylim

the x and y limits of the plot

col, lty, lwd

the line colours, types and widths for lines appearing in plot and legend

add

if TRUE, add to the current plot

frame.plot

an integer indicating whether a box should be drawn around the plot before the legend (1), after the legend (2), or not at all (0). Logical values are coerced to integer, so TRUE implies 1, and FALSE implies 0

legend

logical; if TRUE (the default) a legend is included with the plot

x.legend, y.legend

the x and y co-ordinates to be used to position the legend. They can be specified by keyword or in any way which is accepted by xy.coords

bty

legend box type

box.col

line colour for the legend box

bg.legend

background colour for the legend box

cex.legend

character expanson faftor for legend

x.intersp, y.intersp

horizontal and vertical character interspacing for legend

inset

the legends inset distance from the margins as a fraction of the plot region

xpd.legend

the value of xpd to be used while drawing the legend

horiz

logical; if TRUE, set the legend horizontally rather than vertically

...

further arguments passed to density

Value

An invisible list of the "density" objects the plot is based on.

See Also

density, ahist

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set.seed(1)
dl <- list("Unif-1"=runif(80, -2.1, 2.1), 
           "Unif-2"=runif(70, -1.5, 1.5), 
         "Normal-1"=rnorm(50, 0, 0.866), 
         "Normal-2"=rnorm(90, 0, 1))

# sqrt((sd^2)*12) # sd to unif range

md <- multidensity(dl)
head(md, 2)

multidensity(dl, adj=1.2, x.leg="topright", frame=FALSE, inset=-0.02, lty=1)
multidensity(dl, x.legend="top", horiz=TRUE, cex.legend=0.5,
  inset=-0.05, bg.legend="white")

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.