# "density" type convenience string
tinyplot(~Sepal.Length, data = iris, type = "density")
# grouped density example
tinyplot(~Sepal.Length | Species, data = iris, type = "density")
# use `bg = "by"` (or, equivalent `fill = "by"`) to get filled densities
tinyplot(~Sepal.Length | Species, data = iris, type = "density", fill = "by")
# use `type_density()` to pass extra arguments for customization
tinyplot(
~Sepal.Length | Species, data = iris,
type = type_density(bw = "SJ"),
main = "Bandwidth computed using Sheather & Jones (1991)"
)
# The default for grouped density plots is to use the mean of the
# individual subgroup bandwidths (weighted by group size) as the
# joint bandwidth. Alternatively, the bandwidth from the "full"
# data or separate individual bandwidths ("none") can be used.
tinyplot(~Sepal.Length | Species, data = iris,
ylim = c(0, 1.25), type = "density") # mean (default)
tinyplot_add(joint.bw = "full", lty = 2) # full data
tinyplot_add(joint.bw = "none", lty = 3) # none (individual)
legend("topright", c("Mean", "Full", "None"), lty = 1:3, bty = "n", title = "Joint BW")
Run the code above in your browser using DataLab