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) }