ggplot_waterfall: Plots a water fall plot

Description Usage Arguments Value Cosmetic Tips Also See Examples

View source: R/ggplot_waterfall.R

Description

A waterfall plot highlights the change in the time series rather than the value of the time series itself.

Usage

1
2
ggplot_waterfall(dtData, cXColumnName, cYColumnName, nArrowSize = 0.25,
  vcGroupingColumnNames = NULL)

Arguments

dtData

Data set which may include other columns apart from the columns mapped to x and y .

cXColumnName

Column name of the x mapping.

cYColumnName

Column name of the y mapping.

nArrowSize

the size of the arrow head on the plot in cm

vcGroupingColumnNames

The set of columns which together define the group for the chart to operate between. If you plan to facet your plot, you should specify the same column names to this argument.

Value

Returns a gpplot friendly object which means the user can use ggplot scales to modify the look, add more geoms, etc.

Cosmetic Tips

The minimalist look can be achieved by appending the following chunk of code to the output object: + xlab(NULL) + ylab(NULL) + scale_fill_continuous(low = 'green', high = 'red') + theme( axis.text = element_blank(), axis.ticks = element_blank(), legend.position = 'none', strip.background = element_blank(), # strip.text = element_blank(), # useful if only one year of data plot.background = element_blank(), panel.background = element_blank(), panel.border = element_blank(), panel.grid = element_blank(), panel.border = element_blank() )

Also See

stat_waterfall, a flexible but less polished alternative.

Examples

1
2
3
4
5
6
7
8
9
{
library(ggplot2)
set.seed(1)
dfData = data.frame(x = 1:100, y = cumsum(rnorm(100)))
ggplot_waterfall(
   dtData = dfData,
   'x',
   'y'
)}

Example output

Loading required package: ggplot2

ggTimeSeries documentation built on Jan. 23, 2022, 5:07 p.m.