x <- rnorm(1000,0,1)
y <- rnorm(1000,0,2)
z <- rnorm(1000,2,1.5)
# the input of the following function MUST be a numeric list
PlotMultiDens(list(x=x,y=y,z=z))
# use area fill
PlotMultiDens(list(x=x,y=y,z=z), fill=SetAlpha(c("red","green","blue"), 0.4))
PlotMultiDens( x=split(d.pizza$delivery_min, d.pizza$driver), na.rm=TRUE
, main="delivery time ~ driver", xlab="delivery time [min]", ylab="density"
, lwd=1:7, lty=1:7
, panel.first=grid())
# this example demonstrates the definition of different line types and -colors
# an is NOT thought as recommendation for good plotting practice... :-)
# the formula interface
PlotMultiDens(delivery_min ~ driver, data=d.pizza)
# recyling of the density parameters
res <- PlotMultiDens(x=split(d.pizza$temperature, d.pizza$driver),
args.dens = list(bw=c(5,2), kernel=c("rect","epanechnikov")), na.rm=TRUE)
res
# compare bandwidths
PlotMultiDens(x=split(d.pizza$temperature, d.pizza$driver)[1],
args.dens = list(bw=c(1:5)), na.rm=TRUE,
args.legend=NA, main="Compare bw")
legend(x="topright", legend=gettextf("bw = %s", 1:5), fill=rainbow(5))
Run the code above in your browser using DataLab