Description Usage Arguments Details See Also Examples
View source: R/gg-constructors.R
Creates a bar chart, showing how the changes from left-most observation to the right-most observation.
1 2 |
aes |
The aesthetic that defines the layer. Will inherit (or parts thereof) if omitted. |
data |
The data to be used. Will inherit from parent if missing. |
colour |
A colour to be applied to all of the series, or (if your aesthetic has a group), a vector of colours that will be cycled through to consecutive group elements. |
barcol |
(optional) Outline colours for each bar series |
panel |
(default = "1") Which panel of the graph to place this layer on. You can specify a vector of panels (e.g. 'panel = c("1","3")') to apply the layer to multiple panels at once. |
You should ensure that your data are ordered so that your first observation is the observation you want the waterfall to 'start' from, and your last observation the one you want the waterfall to 'end' at. Do this by specifying an 'order' in your aesthetic.
Setting groups (and colours) is a good idea: create a group to differentiate your start and end observations and your positive and negative observations (separately colouring positive and negative makes the graph easier to read).
This layer type should be considered experimental and may undergo breaking changes.
vignette("plotting-options", package = "arphit")
for a
detailed description of all the plotting options
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # Simple waterfall graph
data <- data.frame(x = letters[1:6], y = c(2,1,-0.5,-0.2,0.4,2.7))
arphitgg(data) + agg_waterfall(agg_aes(x=x,y=y,order=x))
# Waterfall graph separately colouring positive and negative changes
data <- data.frame(x = letters[1:6], y = c(2,1,-0.5,-0.2,0.4,2.7))
arphitgg(data) + agg_waterfall(agg_aes(x=x,y=y,group=y<0,order=x))
# Waterfall graphs with multiple groups per x observation
data <- data.frame(x = c('start','a','a','b','b','end'),
y = c(1, 0.5, -0.4, 0.2, 0.1, 1.4),
group = c(1, 2, 3, 2, 3, 4),
order = c(1,2,2,3,3,4))
arphitgg(data) +
agg_waterfall(agg_aes(x=x,y=y,group=group,order=order))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.