The goal of r2dii.plot is to help you plot 2DII data in an informative, beautiful, and easy way.
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")
::install_github("2DegreesInvesting/r2dii.plot") devtools
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)
qplot_*()
to quickly get a plot with standard
titles and labels.# `data` must meet documented "Requirements"
<- market_share %>%
data filter(
== "power",
sector == "renewablescap",
technology == "global",
region == "demo_2020"
scenario_source
)
qplot_trajectory(data)
plot_*()
for a more “bare” plot that you can
customize yourself by modifying the input data and applying
ggplot2
functions.<- market_share %>%
data filter(
== "power",
sector == "renewablescap",
technology == "global",
region == "demo_2020",
scenario_source between(year, 2020, 2035)
%>%
) mutate(
label = case_when(
== "projected" ~ "Your Portfolio",
metric == "corporate_economy" ~ "Benchmark (Corp. Econ.)",
metric == "target_sds" ~ "SDS Scenario",
metric == "target_sps" ~ "SPS Scenario",
metric == "target_cps" ~ "CPS Scenario",
metric 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)"
)#> Warning: The `data` argument of `plot_trajectory()` must be prepped already as of r2dii.plot 0.4.0.
#> • From the next release you will need to call `r2dii.plot::plot_trajectory(data)`
#> prior to calling `r2dii.plot::plot_trajectory()`.
#> • Alternatively custom data preparation will also become possible.
For examples of other plots and data sets please visit Get started with r2dii.plot.
This project has received funding from the European Union LIFE program and the International Climate Initiative (IKI). The Federal Ministry for the Environment, Nature Conservation and Nuclear Safety (BMU) supports this initiative on the basis of a decision adopted by the German Bundestag. The views expressed are the sole responsibility of the authors and do not necessarily reflect the views of the funders. The funders are not responsible for any use that may be made of the information it contains.