plot_kaya: Plot Kaya-identity variable

Description Usage Arguments Value Examples

View source: R/plot_kaya.R

Description

Plot Kaya-identity variable

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
plot_kaya(
  kaya_data,
  variable,
  start_year = NA,
  stop_year = NA,
  y_lab = NULL,
  log_scale = FALSE,
  trend_line = FALSE,
  points = TRUE,
  font_size = 20,
  colors = NULL,
  pre_color = NULL,
  post_color = NULL,
  in_range_color = NULL,
  trend_color = NULL
)

Arguments

kaya_data

A tibble with Kaya-identity data

variable

The name of the variable to plot (character)

start_year

The year to start highlighting the data (should correspond to the beginning of the trend calculation). Set to NULL to turn off highlighting.

stop_year

The year to stop highlighting the data (should correspond to the beginning of the trend calculation). Set to NULL to turn off highlighting.

y_lab

Optional label for the y-axis

log_scale

Use log scale for y axis

trend_line

Include a trend line

points

Plot points in addition to the line.

font_size

Base size of the font for axis labels and titles.

colors

Named vector of colors to use for the plot. Elements should include PRE, POST, IN-RANGE, and TREND, which respectively give the colors for the portion of the plot before start_year, after stop_year, between start_year and stop_year, and the trend line.

pre_color

Override default color for the portion of the chart before start_year.

post_color

Override default color for the portion of the chart after stop_year.

in_range_color

Override default color for the portion of the chart between start_year and stop_year.

trend_color

Override default color for the trend line.

Value

A plot object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
china <- get_kaya_data("China")
plot_kaya(china, "F", 2001, 2011)
## Not run: 
uk <- get_kaya_data("United Kingdom")
plot_kaya(uk, "e", log_scale = TRUE, trend_line = TRUE)
plot_kaya(uk, "e", log_scale = TRUE, trend_line = TRUE,
          start_year = 1970, stop_year = 2000,
          colors = c(PRE="limegreen", POST="darkgreen",
                     "IN-RANGE" = "cadetblue", TREMD="orange"))
plot_kaya(uk, "e", log_scale = TRUE, trend_line = TRUE,
          start_year = 1970, stop_year = 2000,
          pre_color = "limegreen", post_color = "limegreen",
          trend_color = "magenta")

## End(Not run)

world <- get_kaya_data("World")
plot_kaya(world, "g", 1982, log_scale = TRUE, trend_line = TRUE)

kayadata documentation built on Oct. 25, 2021, 9:07 a.m.