ggplot_bar_vts: Stacked bar plot with variable bar width

Description Usage Arguments Details Value Author(s) Examples

View source: R/ggplot_bar_vts.R

Description

ggplot_bar_vts() creates a bar plot with variable bar widths and is intended for plotting time series with variable time-step width.

Usage

1
2
ggplot_bar_vts(data, mapping = aes(x = period, y = value, fill = variable),
               ts = NULL, gaps = 0.1)

Arguments

data

a data frame

mapping

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

ts

data frame linking periods to time steps widths and positons; defaults to REMIND values

gaps

gaps between bars as a fraction of the lowest bar width; defaults 0.1 (* 5 years = 0.5 years)

Details

If ts is NULL, values for the use with REMIND data are used. If other values are needed, pass a data frame with the columns period (coinciding with the column assigned to the x aesthetic in data), .ts (containing the desired width of the bars), and .positon (containing the center point of the bars). 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(tidyr)
require(ggplot2)
data.frame(period = c(seq(2005, 2060, by = 5), seq(2070, 2100, by = 10))) %>%
    mutate(linear = (period - 2005) / 10,
           logarithmic = log10(period - 2000),
           negative = -(logarithmic / (linear + 1))) %>%
    gather(variable, value, -period) %>%
    ggplot_bar_vts()

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