From 60690746a2767dc478005fc48cd9726cf3322e01 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Thu, 15 Jan 2026 15:59:40 +0100 Subject: [PATCH 1/2] add new parameter target to showLinePlots --- R/showLinePlots.R | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/R/showLinePlots.R b/R/showLinePlots.R index 0d9bb33..d9924c1 100644 --- a/R/showLinePlots.R +++ b/R/showLinePlots.R @@ -27,7 +27,7 @@ showLinePlots <- function(...) { #' Create Line Plots #' #' Creates the line plots for showLinePlots. -#' @param vars A character vector of variables to be plotted. Defaults to all +#' @param vars A character vector of variables to be plotted. Defaults to all #' variables in `data`. #' @param histVars A character vector of historical variables to be plotted. #' Defaults to `vars`. @@ -39,6 +39,7 @@ showLinePlots <- function(...) { #' exclude. #' @param color.dim.manual optional vector with manual colors replacing default #' colors of color.dim, default is \code{NULL}. +#' @param target optional model variable to be plotted with dots (indicating targets) #' @param vlines period used for vertical line #' @return Arranged plots #' @inheritParams createAreaAndBarPlots @@ -57,6 +58,7 @@ createLinePlots <- function( mainReg = getOption("mip.mainReg"), color.dim.manual = NULL, histModelsExclude = character(), + target = NULL, vlines = NULL ) { # Validate function arguments. @@ -135,9 +137,24 @@ createLinePlots <- function( mapping = aes(x = .data$period, y = .data$value)) } - if (! is.null(vlines)) { + if (!is.null(vlines)) { p1 <- p1 + geom_vline(xintercept = vlines, linetype = 3) } + + if (!is.null(target)) { + + targets <- as.quitte(data) %>% + filter(!is.na(.data$value), .data$region == .env$mainReg, + .data$scenario != "historical", .data$variable == target) %>% + droplevels() + + p1 <- p1 + + geom_point(data = targets, + aes(x = .data$period, y = .data$value, shape = .data$scenario)) + + guides(shape = guide_legend(title = "Target", + theme = theme(legend.direction = "vertical",))) + } + } if (NROW(dRegiScen) == 0) { p2 <- ggplot() + theme_minimal() @@ -155,9 +172,25 @@ createLinePlots <- function( color.dim.manual = color.dim.manual, color.dim.manual.hist = color.dim.manual.hist[regiHistModels] ) + if (!is.null(vlines)) { p2 <- p2 + geom_vline(xintercept = vlines, linetype = 3) } + + if (!is.null(target)) { + + targets <- as.quitte(data) %>% + filter(!is.na(.data$value), .data$region != .env$mainReg, + .data$scenario != "historical", .data$variable == target) %>% + droplevels() + + p2 <- p2 + + geom_point(data = targets, + aes(x = .data$period, y = .data$value, shape = .data$scenario)) + + guides(shape = guide_legend(title = "Target", + theme = theme(legend.direction = "vertical"))) + + } } # If a legend of the plots can be used as common legend for both plots, From 4674dfc5abc281c06a416e2ce0fc125a94b1a74b Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Thu, 15 Jan 2026 16:12:14 +0100 Subject: [PATCH 2/2] increment version --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/showLinePlots.R | 2 +- README.md | 10 +++++----- man/createLinePlots.Rd | 5 ++++- man/showLinePlots.Rd | 3 ++- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index ab2ed84..0ba34b7 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '31825080' +ValidationKey: '31889144' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index b0588c1..c358fc7 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'mip: Comparison of multi-model runs' -version: 0.155.7 -date-released: '2025-12-18' +version: 0.155.8 +date-released: '2026-01-15' abstract: Package contains generic functions to produce comparison plots of multi-model runs. authors: diff --git a/DESCRIPTION b/DESCRIPTION index f9eed60..fc71589 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mip Title: Comparison of multi-model runs -Version: 0.155.7 -Date: 2025-12-18 +Version: 0.155.8 +Date: 2026-01-15 Authors@R: c( person("David", "Klein", , "dklein@pik-potsdam.de", role = c("aut", "cre")), person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = "aut"), diff --git a/R/showLinePlots.R b/R/showLinePlots.R index d9924c1..09619ed 100644 --- a/R/showLinePlots.R +++ b/R/showLinePlots.R @@ -39,7 +39,7 @@ showLinePlots <- function(...) { #' exclude. #' @param color.dim.manual optional vector with manual colors replacing default #' colors of color.dim, default is \code{NULL}. -#' @param target optional model variable to be plotted with dots (indicating targets) +#' @param target optional string, model variable to be plotted with dots (indicating targets) #' @param vlines period used for vertical line #' @return Arranged plots #' @inheritParams createAreaAndBarPlots diff --git a/README.md b/README.md index 19896df..c07f893 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Comparison of multi-model runs -R package **mip**, version **0.155.7** +R package **mip**, version **0.155.8** [![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 , Version: 0.155.7, . +Klein D, Dietrich J, Baumstark L, Humpenoeder F, Stevanovic M, Wirth S, Führlich P, Richters O, Rüter T, Salzwedel R, Lécuyer F (2026). "mip: Comparison of multi-model runs." doi:10.5281/zenodo.1158586 , Version: 0.155.8, . A BibTeX entry for LaTeX users is @@ -56,9 +56,9 @@ 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 and Tonn Rüter and Robert Salzwedel and Fabrice Lécuyer}, doi = {10.5281/zenodo.1158586}, - date = {2025-12-18}, - year = {2025}, + date = {2026-01-15}, + year = {2026}, url = {https://github.com/pik-piam/mip}, - note = {Version: 0.155.7}, + note = {Version: 0.155.8}, } ``` diff --git a/man/createLinePlots.Rd b/man/createLinePlots.Rd index f9d6e59..210bfe6 100644 --- a/man/createLinePlots.Rd +++ b/man/createLinePlots.Rd @@ -15,6 +15,7 @@ createLinePlots( mainReg = getOption("mip.mainReg"), color.dim.manual = NULL, histModelsExclude = character(), + target = NULL, vlines = NULL ) } @@ -22,7 +23,7 @@ createLinePlots( \item{data}{A quitte object or an object that can be transformed into a quitte object.} -\item{vars}{A character vector of variables to be plotted. Defaults to all +\item{vars}{A character vector of variables to be plotted. Defaults to all variables in `data`.} \item{histVars}{A character vector of historical variables to be plotted. @@ -45,6 +46,8 @@ colors of color.dim, default is \code{NULL}.} \item{histModelsExclude}{A character vector with historical models to exclude.} +\item{target}{optional string, model variable to be plotted with dots (indicating targets)} + \item{vlines}{period used for vertical line} } \value{ diff --git a/man/showLinePlots.Rd b/man/showLinePlots.Rd index 5907006..e0bc824 100644 --- a/man/showLinePlots.Rd +++ b/man/showLinePlots.Rd @@ -10,7 +10,7 @@ showLinePlots(...) \item{...}{ Arguments passed on to \code{\link[=createLinePlots]{createLinePlots}} \describe{ - \item{\code{vars}}{A character vector of variables to be plotted. Defaults to all + \item{\code{vars}}{A character vector of variables to be plotted. Defaults to all variables in `data`.} \item{\code{histVars}}{A character vector of historical variables to be plotted. Defaults to `vars`.} @@ -22,6 +22,7 @@ Defaults to `vars`.} exclude.} \item{\code{color.dim.manual}}{optional vector with manual colors replacing default colors of color.dim, default is \code{NULL}.} + \item{\code{target}}{optional string, model variable to be plotted with dots (indicating targets)} \item{\code{vlines}}{period used for vertical line} \item{\code{data}}{A quitte object or an object that can be transformed into a quitte object.}