geom_waterfall: geom_waterfall Creates a ggplot that makes a smooth rank over...

Description Usage Arguments Value Examples

View source: R/geom_waterfall.R

Description

geom_waterfall

Creates a ggplot that makes a smooth rank over time. To change the 'smooth' argument you need to put it outside of the 'aes' of the geom. Uses the x and y aestethics. Usually you want to compare multiple lines and if so, use the 'color' aestethic. To change the direction of the curve to 'vertical' set 'direction = "y'

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
geom_waterfall(
  mapping = NULL,
  data = NULL,
  geom = "rect",
  position = "identity",
  na.rm = FALSE,
  show.legend = NA,
  inherit.aes = TRUE,
  grand_total = TRUE,
  ...
)

Arguments

mapping

provide you own mapping. both x and y need to be numeric.

data

provide you own data

geom

change geom

position

change position

na.rm

remove missing values

show.legend

show legend in plot

inherit.aes

should the geom inherits aestethics

...

other arguments to be passed to the geom

smooth

how much smooth should the curve have? More means steeper curve.

direction

the character x or y depending of smoothing direction

Value

ggplot layer

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library(ggplot2)
library(ggbump)
df <- data.frame(country = c(
  "India", "India", "India",
  "Sweden", "Sweden", "Sweden",
  "Germany", "Germany", "Germany",
  "Finland", "Finland", "Finland"),
year = c(2011, 2012, 2013,
2011, 2012, 2013,
2011, 2012, 2013,
2011, 2012, 2013),
month = c("January", "July", "November",
          "January", "July", "November",
          "January", "July", "November",
          "January", "July", "November"),
rank = c(4, 2, 2, 3, 1, 4, 2, 3, 1, 1, 4, 3))

# Contingous x axis
ggplot(df, aes(year, rank, color = country)) +
  geom_point(size = 10) +
  geom_bump(size = 2)

# Discrete x axis
ggplot(df, aes(month, rank, color = country)) +
  geom_bump(size = 2)

oskjoh/ggwaterfall documentation built on Dec. 22, 2021, 5:19 a.m.