Helper for creating a density plot
Usage
bb_densityplot(
bb,
data,
mapping = NULL,
stacked = FALSE,
stat = "density",
fill = FALSE,
...
)
Arguments
- bb
A
billboard
htmlwidget
object.- data
A
data.frame
or avector
, the first column will be used to calculate density ifx
isNULL
.- mapping
Mapping of variables on the chart, see
bbaes
.- stacked
Logical, create a stacked density plot.
- stat
Stat to compute :
density
orcount
.- fill
Produce a conditional density estimate, this option force
stacked = TRUE
.- ...
Arguments passed to
density
.
Examples
# With a vector
billboarder() %>%
bb_densityplot(data = rnorm(1e4))
data("diamonds", package = "ggplot2")
# density plot with one variable
billboarder() %>%
bb_densityplot(data = diamonds, x = "carat")
# Same with mapping
billboarder() %>%
bb_densityplot(diamonds, bbaes(carat))
# With a grouping variable
billboarder() %>%
bb_densityplot(data = diamonds, x = "depth", group = "cut") %>%
bb_x_axis(min = 55, max = 70)
# Same with mapping
billboarder() %>%
bb_densityplot(diamonds, bbaes(depth, group = cut)) %>%
bb_x_axis(min = 55, max = 70)
# a stacked density plot using count as statistic
bb <- billboarder() %>%
bb_densityplot(diamonds, bbaes(depth, group = cut),
stacked = TRUE, stat = "count") %>%
bb_x_axis(min = 55, max = 70)
bb
# changing order
bb %>% bb_data(order = "asc")