ggplot_bar_stacked_dodged: Stacked and dodged bar plot

Description Usage Arguments Details Value Author(s) Examples

View source: R/ggplot_bar_stacked_dodged.R

Description

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.

Usage

1

Arguments

data

a data frame

mapping

aes() mapping with aesthetics x, y, fill and dodge.

Details

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.

Value

a ggplot() like object

Author(s)

Michaja Pehl

Examples

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))

michaja/quitte documentation built on May 22, 2019, 9:53 p.m.