From 64fa10032f99490a5998589161574109484ee769 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 24 Feb 2021 14:46:10 +0100 Subject: Reset graphical parameters with on.exit() plot.mixed.mmkin did not reset graphical parameters at all. The other plotting functions did not use on.exit, so this change should make the use of the plotting functions safer. --- R/mkinparplot.R | 4 ++-- R/plot.mixed.mmkin.R | 1 + R/plot.mkinfit.R | 2 +- R/plot.mmkin.R | 3 +-- tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg | 5 +++++ tests/figs/plotting/mixed-model-fit-for-nlme-object.svg | 5 +++++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/R/mkinparplot.R b/R/mkinparplot.R index f9abab5b..8cae30fb 100644 --- a/R/mkinparplot.R +++ b/R/mkinparplot.R @@ -32,7 +32,8 @@ mkinparplot <- function(object) { fractions.optim = length(fractions.optim)) n.plot <- n.plot[n.plot > 0] - oldpars <- par(no.readonly = TRUE) + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar, no.readonly = TRUE)) layout(matrix(1:length(n.plot), ncol = 1), heights = n.plot + 1) s <- summary(object) @@ -71,5 +72,4 @@ mkinparplot <- function(object) { as.numeric(values.upper.nonInf), parname_index, code = 3, angle = 90, length = 0.05)) } - par(oldpars) } diff --git a/R/plot.mixed.mmkin.R b/R/plot.mixed.mmkin.R index 5a0b7412..4c1f1531 100644 --- a/R/plot.mixed.mmkin.R +++ b/R/plot.mixed.mmkin.R @@ -146,6 +146,7 @@ plot.mixed.mmkin <- function(x, # Start of graphical section oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar, no.readonly = TRUE)) n_plot_rows = length(obs_vars) n_plots = n_plot_rows * 2 diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R index eced40a4..2e319aae 100644 --- a/R/plot.mkinfit.R +++ b/R/plot.mkinfit.R @@ -161,6 +161,7 @@ plot.mkinfit <- function(x, fit = x, if (do_layout) { # Layout should be restored afterwards oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar, no.readonly = TRUE)) # If the observed variables are shown separately, or if requested, do row layout if (sep_obs | row_layout) { @@ -287,7 +288,6 @@ plot.mkinfit <- function(x, fit = x, legend = FALSE, frame = frame) } } - if (do_layout) par(oldpar, no.readonly = TRUE) } #' @rdname plot.mkinfit diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R index f8ed1f9a..2166b30e 100644 --- a/R/plot.mmkin.R +++ b/R/plot.mmkin.R @@ -65,6 +65,7 @@ plot.mmkin <- function(x, main = "auto", legends = 1, { oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar, no.readonly = TRUE)) n.m <- nrow(x) n.d <- ncol(x) @@ -153,6 +154,4 @@ plot.mmkin <- function(x, main = "auto", legends = 1, } mtext(paste(fit_name, "residuals"), cex = cex, line = 0.4) } - - par(oldpar, no.readonly = TRUE) } diff --git a/tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg b/tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg index e022af25..b3abac39 100644 --- a/tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg +++ b/tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg @@ -710,4 +710,9 @@ + + + + + diff --git a/tests/figs/plotting/mixed-model-fit-for-nlme-object.svg b/tests/figs/plotting/mixed-model-fit-for-nlme-object.svg index b2955239..3eb2b0f8 100644 --- a/tests/figs/plotting/mixed-model-fit-for-nlme-object.svg +++ b/tests/figs/plotting/mixed-model-fit-for-nlme-object.svg @@ -1348,4 +1348,9 @@ + + + + + -- cgit v1.2.1 From 96ebc42e4c779e2bc496316a5cb9055bbefc9e40 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 24 Feb 2021 15:01:23 +0100 Subject: Rebuild docs --- DESCRIPTION | 4 ++-- NEWS.md | 6 ++++++ docs/404.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 10 +++++++++- docs/pkgdown.yml | 2 +- docs/reference/Rplot001.png | Bin 27554 -> 27746 bytes docs/reference/Rplot002.png | Bin 59342 -> 59394 bytes docs/reference/endpoints.html | 2 +- docs/reference/index.html | 2 +- docs/reference/plot.mixed.mmkin-1.png | Bin 84734 -> 85433 bytes docs/reference/plot.mixed.mmkin-2.png | Bin 173916 -> 174061 bytes docs/reference/plot.mixed.mmkin.html | 2 +- 15 files changed, 25 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 18701d12..176c3039 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data -Version: 1.0.3 -Date: 2021-02-15 +Version: 1.0.4 +Date: 2021-02-24 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de", diff --git a/NEWS.md b/NEWS.md index 440286ea..f96eabf7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# mkin 1.0.4 (2021-02-24) + +- 'plot.mixed.mmkin': Reset graphical parameters on exit + +- All plotting functions setting graphical parameters: Use on.exit() for resetting graphical parameters + # mkin 1.0.3 (2021-02-15) - Review and update README, the 'Introduction to mkin' vignette and some of the help pages diff --git a/docs/404.html b/docs/404.html index 48cba3d7..86397bff 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ mkin - 1.0.3 + 1.0.4 diff --git a/docs/articles/index.html b/docs/articles/index.html index 22753e8d..8e05af32 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -71,7 +71,7 @@ mkin - 1.0.3 + 1.0.4 diff --git a/docs/authors.html b/docs/authors.html index 61d29bf0..533ca458 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ mkin - 1.0.3 + 1.0.4 diff --git a/docs/index.html b/docs/index.html index 82aab7f3..72fd88f4 100644 --- a/docs/index.html +++ b/docs/index.html @@ -37,7 +37,7 @@ mkin - 1.0.3 + 1.0.4 diff --git a/docs/news/index.html b/docs/news/index.html index 1428dc78..d6b2a8fb 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ mkin - 1.0.3 + 1.0.4 @@ -141,6 +141,14 @@ Source: NEWS.md +
+

+mkin 1.0.4 (2021-02-24)

+
    +
  • ‘plot.mixed.mmkin’: Reset graphical parameters on exit

  • +
  • All plotting functions setting graphical parameters: Use on.exit() for resetting graphical parameters

  • +
+

mkin 1.0.3 (2021-02-15)

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 71325fcc..76b2f3b9 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: web_only/NAFTA_examples: NAFTA_examples.html web_only/benchmarks: benchmarks.html web_only/compiled_models: compiled_models.html -last_built: 2021-02-15T18:11Z +last_built: 2021-02-24T14:00Z urls: reference: https://pkgdown.jrwb.de/mkin/reference article: https://pkgdown.jrwb.de/mkin/articles diff --git a/docs/reference/Rplot001.png b/docs/reference/Rplot001.png index 762a3dd4..1cbcb153 100644 Binary files a/docs/reference/Rplot001.png and b/docs/reference/Rplot001.png differ diff --git a/docs/reference/Rplot002.png b/docs/reference/Rplot002.png index d24e35b4..745d583d 100644 Binary files a/docs/reference/Rplot002.png and b/docs/reference/Rplot002.png differ diff --git a/docs/reference/endpoints.html b/docs/reference/endpoints.html index 584079d2..a83276f3 100644 --- a/docs/reference/endpoints.html +++ b/docs/reference/endpoints.html @@ -78,7 +78,7 @@ advantage that the SFORB model can also be used for metabolites." /> mkin - 1.0.3 + 1.0.4
diff --git a/docs/reference/index.html b/docs/reference/index.html index e21304b9..36ef6367 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ mkin - 1.0.3 + 1.0.4 diff --git a/docs/reference/plot.mixed.mmkin-1.png b/docs/reference/plot.mixed.mmkin-1.png index 9c9a2211..2224d96e 100644 Binary files a/docs/reference/plot.mixed.mmkin-1.png and b/docs/reference/plot.mixed.mmkin-1.png differ diff --git a/docs/reference/plot.mixed.mmkin-2.png b/docs/reference/plot.mixed.mmkin-2.png index 0f66ff0f..28168495 100644 Binary files a/docs/reference/plot.mixed.mmkin-2.png and b/docs/reference/plot.mixed.mmkin-2.png differ diff --git a/docs/reference/plot.mixed.mmkin.html b/docs/reference/plot.mixed.mmkin.html index 4b72a308..b75fa6e6 100644 --- a/docs/reference/plot.mixed.mmkin.html +++ b/docs/reference/plot.mixed.mmkin.html @@ -72,7 +72,7 @@ mkin - 1.0.3 + 1.0.4 -- cgit v1.2.1