Skip to content

Commit

Permalink
Align timeline examples (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
MonikaFu authored Jun 8, 2021
1 parent 3a3b1ca commit 46833c7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
12 changes: 12 additions & 0 deletions vignettes/articles/r2dii-plot-X.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ sda %>%
plot_timelineX(extrapolate = TRUE) + labs(title = "Timeline plot")
```

You can further customize your plot by adding a custom manual scale using
`ggplot` function `scale_colour_manual()` with custom legend labels.

```{r}
sda %>%
filter(sector == "cement") %>%
plot_timelineX(extrapolate = TRUE) +
scale_color_manual(
values = c("#4a5e54", "#a63d57", "#78c4d6", "#f2e06e"),
labels = c("Proj.", "Corp. Economy", "Target (demo)", "Adj. Scenario (demo)"))
```

### Techmix

Use `plot_techmixX()` with `market_share`-like data. Again, learn which rows to
Expand Down
21 changes: 19 additions & 2 deletions vignettes/articles/r2dii-plot-Y.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,32 @@ cement <- prep_timelineY(sda, sector_filter = "cement")
cement <- prep_timelineY(filter(sda, sector == "cement"))
cement
# Default recoding
plot_timelineY(cement)
```

You can further polish your plot. Your options are limitless but these are
some typical things you may do:

* Pick a narrower time range (by filtering your data using `dplyr`).
* Extrapolate the timeline.
* Add a title.

```{r}
cement <- prep_timelineY(
filter(sda, sector == "cement", year >= 2020),
extrapolate = TRUE)
plot_timelineY(cement) +
labs(title = "Timeline plot")
```

* `plot_timelineY()` defaults to recoding `line_name` to title case, and allows
custom recoding and colour setting via a data frame passed to the argument
`specs`.

```{r}
# Default recoding
plot_timelineY(cement)
# Custom recoding
custom <- tribble(
Expand Down

0 comments on commit 46833c7

Please sign in to comment.