Description Usage Arguments Details Value Author(s) Examples
View source: R/ggplot_bar_stacked_dodged.R
ggplot_bar_stacked_dodged() creates a bar plot with both stacked
(different categories atop each other) and dodged (different categories along
the x-axis) positioning. Useful for showing more dimensions.
1  | ggplot_bar_stacked_dodged(data, mapping)
 | 
data | 
 a data frame  | 
mapping | 
 
  | 
The fill dimension will be stacked and the dodge
dimension spread along the x-axis. Use further ggplot2
functions like scales, themes and facets as usual. Automatically
splits positive and negative values for plotting above and below
zero bars.
a ggplot() like object
Michaja Pehl
1 2 3 4 5 6 7 8 9  | require(dplyr)
require(ggplot2)
expand.grid(x = as.factor(c("left", "center", "right")),
                  stack = as.factor(c("bottom", "middle", "top")),
                  category = letters[1:4]) %>%
    mutate(value = abs(rnorm(n()))) %>%
    ggplot_bar_stacked_dodged(aes(x = x, y = value, fill = stack,
                                  dodge = category)) +
    guides(fill = guide_legend(reverse = TRUE))
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.