-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
126 lines (103 loc) · 4 KB
/
README.Rmd
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
fig.align = "left",
out.width = "100%"
)
```
# r2dii.plot <img src="man/figures/logo.png" align="right" width="120" />
<!-- badges: start -->
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![Codecov test coverage](https://codecov.io/gh/RMI-PACTA/r2dii.plot/branch/master/graph/badge.svg)](https://app.codecov.io/gh/RMI-PACTA/r2dii.plot?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/r2dii.plot)](https://CRAN.R-project.org/package=r2dii.plot)
[![R-CMD-check](https://github.com/RMI-PACTA/r2dii.plot/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/RMI-PACTA/r2dii.plot/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
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:
```r
install.packages("r2dii.plot")
```
And the development version from GitHub with:
```r
# install.packages("devtools")
devtools::install_github("RMI-PACTA/r2dii.plot")
```
## Example
The r2dii.plot package is designed to work smoothly with other "r2dii" packages
-- [r2dii.data](https://rmi-pacta.github.io/r2dii.data/),
[r2dii.match](https://rmi-pacta.github.io/r2dii.match/), and
[r2dii.analysis](https://rmi-pacta.github.io/r2dii.analysis/). It also
plays well with the [ggplot2](https://ggplot2.tidyverse.org/) 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()`](https://rmi-pacta.github.io/r2dii.analysis/reference/target_market_share.html)
function in the r2dii.analysis package.
```{r setup}
library(ggplot2, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(r2dii.plot)
```
### Plot trajectory chart
* Use `qplot_*()` to quickly get a plot with standard titles and labels.
```{r}
# `data` must meet documented "Requirements"
data <- market_share %>%
filter(
sector == "power",
technology == "renewablescap",
region == "global",
scenario_source == "demo_2020"
)
qplot_trajectory(data)
```
* Use `plot_*()` for a more "bare" plot that you can customize yourself by
modifying the input data and applying `ggplot2` functions.
```{r}
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
)
)
data %>%
prep_trajectory() %>%
plot_trajectory() +
labs(
title = "Power production trajectory for Renewables",
subtitle = "With reference to climate scenarios.",
x = "Year",
y = "Production (normalized to 2020)"
)
```
For examples of other plots and data sets please visit [Get started with
r2dii.plot](https://rmi-pacta.github.io/r2dii.plot/articles/r2dii-plot.html).
## Funding
This project has received funding from the [European Union LIFE
program](https://wayback.archive-it.org/12090/20210412123959/https://ec.europa.eu/easme/en/) 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.