r2dii.plot

Lifecycle: experimental Codecov test coverage R-CMD-check CRAN status

The goal of r2dii.plot is to help you plot 2DII data in an informative, beautiful, and easy way.

Installation

You can install the released version of r2dii.plot from CRAN with:

install.packages("r2dii.plot")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("2DegreesInvesting/r2dii.plot")

Example

The r2dii.plot package is designed to work smoothly with other “r2dii” packages – r2dii.data, r2dii.match, and r2dii.analysis. It also plays well with the ggplot2 package, which helps you customize your plots. Here, we’ll use an example data set that comes with r2dii.plot and that resembles the output of the target_market_share() function in the r2dii.analysis package.

library(ggplot2, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(r2dii.plot)

Plot trajectory chart

# `data` must meet documented "Requirements"
data <- market_share %>%
  filter(
    sector == "power",
    technology == "renewablescap",
    region == "global",
    scenario_source == "demo_2020"
  )

qplot_trajectory(data)
#> Normalizing `production` values to 2020 -- the start year.

data <- market_share %>%
  filter(
    sector == "power",
    technology == "renewablescap",
    region == "global",
    scenario_source == "demo_2020",
    between(year, 2020, 2035)
  ) %>%
  mutate(
    label = case_when(
      metric == "projected" ~ "Your Portfolio",
      metric == "corporate_economy" ~ "Benchmark (Corp. Econ.)",
      metric == "target_sds" ~ "SDS Scenario",
      metric == "target_sps" ~ "SPS Scenario",
      metric == "target_cps" ~ "CPS Scenario",
      TRUE ~ metric
    )
  )

plot_trajectory(data) +
  labs(
    title = "Power production trajectory for Renewables",
    subtitle = "With reference to climate scenarios.",
    x = "Year",
    y = "Production (normalized to 2020)"
  )
#> Normalizing `production` values to 2020 -- the start year.

For examples of other plots and data sets please visit Get started with r2dii.plot.