From 334a49a3091b823ecec31cea11d5e5db344e1214 Mon Sep 17 00:00:00 2001 From: jan Date: Mon, 6 Mar 2023 11:17:33 +0100 Subject: [PATCH] reset par on exit --- R/box_utils.R | 4 ++-- R/measurement_utils.R | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/box_utils.R b/R/box_utils.R index d3ef5ac..733f8bd 100644 --- a/R/box_utils.R +++ b/R/box_utils.R @@ -20,12 +20,12 @@ plot.sensebox = function (x, ..., mar = c(2, 2, 1, 1)) { sf::st_as_sf() %>% sf::st_geometry() - oldpar = par() + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(mar = mar) plot(world, col = 'gray', xlim = bbox[c(1, 3)], ylim = bbox[c(2, 4)], axes = TRUE, ...) plot(geom, add = TRUE, col = x$exposure, ...) legend('left', legend = levels(x$exposure), col = 1:length(x$exposure), pch = 1) - par(mar = oldpar$mar) invisible(x) } diff --git a/R/measurement_utils.R b/R/measurement_utils.R index 004abe8..e593384 100644 --- a/R/measurement_utils.R +++ b/R/measurement_utils.R @@ -1,9 +1,9 @@ #' @export plot.osem_measurements = function (x, ..., mar = c(2, 4, 1, 1)) { - oldpar = par() + oldpar <- par(no.readonly = TRUE) + on.exit(par(oldpar)) par(mar = mar) plot(value~createdAt, x, col = factor(x$sensorId), xlab = NA, ylab = x$unit[1], ...) - par(mar = oldpar$mar) invisible(x) }