-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add features into showMultiLinePlots.R and showMultiLinePlotsByVariable.R #86
Changes from 4 commits
1d32261
bab40d0
ac4caf6
0ac5964
9fbe19c
8fa0418
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Type: Package | ||
Package: mip | ||
Title: Comparison of multi-model runs | ||
Version: 0.147.2 | ||
Date: 2024-02-05 | ||
Version: 0.148.0 | ||
Date: 2024-02-07 | ||
Authors@R: c( | ||
person("David", "Klein", , "[email protected]", role = c("aut", "cre")), | ||
person("Jan Philipp", "Dietrich", , "[email protected]", role = "aut"), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,9 @@ | |
#' @param showHistorical A single logical value. Should historical data be | ||
#' shown? It is not recommended to set this to \code{TRUE} as the resulting | ||
#' plot we probably be quite confusing. | ||
#' @param showGlobal A single logical value. Should global data be | ||
#' shown? Default is false to save space in pdf | ||
#' @param NROW_NUM An integer value. Number of rows of the panel figures | ||
#' @param histRefModel A named character vector identifying the unique model to | ||
#' be chosen for historical data. Use \code{options(mip.histRefModel=<value>)} | ||
#' to set globally. | ||
|
@@ -42,6 +45,8 @@ | |
showMultiLinePlotsByVariable <- function( | ||
data, vars, xVar, scales = "free_y", | ||
showHistorical = FALSE, | ||
showGlobal = FALSE, | ||
NROW_NUM = 1, | ||
mainReg = getOption("mip.mainReg"), | ||
histRefModel = getOption("mip.histRefModel"), | ||
yearsByVariable = getOption("mip.yearsBarPlot") | ||
|
@@ -92,39 +97,46 @@ showMultiLinePlotsByVariable <- function( | |
|
||
label <- paste0("(", paste0(levels(d$unit), collapse = ","), ")") | ||
xLabel <- paste0(xVar, " (", paste0(levels(d$unit.x), collapse = ","), ")") | ||
|
||
|
||
if (showGlobal) { | ||
p1 <- dMainScen %>% | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please double check the indentation here, I think this needs to be indented more because you added the |
||
ggplot(aes(.data$value.x, .data$value)) + | ||
geom_line(aes(linetype = .data$scenario)) + | ||
facet_wrap(vars(.data$variable), scales = scales) + | ||
facet_wrap(vars(.data$variable), scales = scales, nrow = NROW_NUM) + | ||
theme_minimal() + | ||
expand_limits(y = 0) + | ||
ylab(label) + xlab(xLabel) | ||
} | ||
p2 <- dRegiScen %>% | ||
ggplot(aes(.data$value.x, .data$value, color = .data$region)) + | ||
geom_line(aes(linetype = .data$scenario)) + | ||
facet_wrap(vars(.data$variable), scales = scales) + | ||
facet_wrap(vars(.data$variable), scales = scales, nrow = NROW_NUM) + | ||
theme_minimal() + | ||
scale_color_manual(values = plotstyle(regions)) + | ||
expand_limits(y = 0) + | ||
ylab(label) + xlab(xLabel) | ||
|
||
if (showHistorical) { | ||
stopifnot(xVar %in% names(histRefModel)) | ||
if (showGlobal) { | ||
p1 <- p1 + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check indentation |
||
geom_point(data = dMainHist, aes(shape = .data$model)) + | ||
geom_line(data = dMainHist, aes(group = paste0(.data$model, .data$region)), alpha = 0.5) | ||
} | ||
p2 <- p2 + | ||
geom_point(data = dRegiHist, aes(shape = .data$model)) + | ||
geom_line(data = dRegiHist, aes(group = paste0(.data$model, .data$region)), alpha = 0.5) | ||
} | ||
# Add markers for certain years. | ||
if (length(yearsByVariable) > 0) { | ||
if (showGlobal) { | ||
p1 <- p1 + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check indentation |
||
geom_point( | ||
data = dMainScen %>% | ||
filter(.data$period %in% .env$yearsByVariable) %>% | ||
mutate(year = factor(.data$period)), | ||
mapping = aes(.data$value.x, .data$value, shape = .data$year)) | ||
} | ||
p2 <- p2 + | ||
geom_point( | ||
data = dRegiScen %>% | ||
|
@@ -134,8 +146,10 @@ showMultiLinePlotsByVariable <- function( | |
} | ||
|
||
# Show plots. | ||
if (showGlobal) { | ||
print(p1) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please check indentation |
||
cat("\n\n") | ||
} | ||
print(p2) | ||
cat("\n\n") | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Comparison of multi-model runs | ||
|
||
R package **mip**, version **0.147.2** | ||
R package **mip**, version **0.148.0** | ||
|
||
[![CRAN status](https://www.r-pkg.org/badges/version/mip)](https://cran.r-project.org/package=mip) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158586.svg)](https://doi.org/10.5281/zenodo.1158586) [![R build status](https://github.com/pik-piam/mip/workflows/check/badge.svg)](https://github.com/pik-piam/mip/actions) [![codecov](https://codecov.io/gh/pik-piam/mip/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mip) [![r-universe](https://pik-piam.r-universe.dev/badges/mip)](https://pik-piam.r-universe.dev/builds) | ||
|
||
|
@@ -47,7 +47,7 @@ In case of questions / problems please contact David Klein <[email protected] | |
|
||
To cite package **mip** in publications use: | ||
|
||
Klein D, Dietrich J, Baumstark L, Humpenoeder F, Stevanovic M, Wirth S, Führlich P, Richters O (2024). _mip: Comparison of multi-model runs_. doi:10.5281/zenodo.1158586 <https://doi.org/10.5281/zenodo.1158586>, R package version 0.147.2, <https://github.com/pik-piam/mip>. | ||
Klein D, Dietrich J, Baumstark L, Humpenoeder F, Stevanovic M, Wirth S, Führlich P, Richters O (2024). _mip: Comparison of multi-model runs_. doi:10.5281/zenodo.1158586 <https://doi.org/10.5281/zenodo.1158586>, R package version 0.148.0, <https://github.com/pik-piam/mip>. | ||
|
||
A BibTeX entry for LaTeX users is | ||
|
||
|
@@ -56,7 +56,7 @@ A BibTeX entry for LaTeX users is | |
title = {mip: Comparison of multi-model runs}, | ||
author = {David Klein and Jan Philipp Dietrich and Lavinia Baumstark and Florian Humpenoeder and Miodrag Stevanovic and Stephen Wirth and Pascal Führlich and Oliver Richters}, | ||
year = {2024}, | ||
note = {R package version 0.147.2}, | ||
note = {R package version 0.148.0}, | ||
doi = {10.5281/zenodo.1158586}, | ||
url = {https://github.com/pik-piam/mip}, | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This argument name would be more in line with our camelCase naming convention