Add bar stack
Usage
add_barstack_absolute(plot, width = 0.8, reverse = FALSE, ...)
add_barstack_relative(plot, width = 0.8, reverse = FALSE, ...)
Arguments
- plot
A
tidyplot
generated with the functiontidyplot()
.- width
Width of the plot area. Defaults to
50
.- reverse
Whether the order should be reversed or not. Defaults to
FALSE
, meaning not reversed.- ...
Arguments passed on to the
geom
function.
Examples
# for a `count` only provide `color`
# `count` of the data points in each `energy_type` category
energy %>%
tidyplot(color = energy_type) %>%
add_barstack_absolute()
energy %>%
tidyplot(color = energy_type) %>%
add_barstack_relative()
# for a `sum` provide `color` and `y`
# `sum` of `power` in each `energy_type` category
energy %>%
tidyplot(y = power, color = energy_type) %>%
add_barstack_absolute()
energy %>%
tidyplot(y = power, color = energy_type) %>%
add_barstack_relative()
# Include variable on second axis
energy %>%
tidyplot(x = year, y = power, color = energy_type) %>%
add_barstack_absolute()
energy %>%
tidyplot(x = year, y = power, color = energy_type) %>%
add_barstack_relative()
# Flip x and y-axis
energy %>%
tidyplot(x = power, y = year, color = energy_type) %>%
add_barstack_absolute(orientation = "y")
energy %>%
tidyplot(x = power, y = year, color = energy_type) %>%
add_barstack_relative(orientation = "y")