From 11d84f1f419a9d53ea9af4dc3dd66b67e00b93a5 Mon Sep 17 00:00:00 2001 From: Dan Sheldon Date: Tue, 14 Jan 2025 17:34:57 -0500 Subject: [PATCH] 1. Bugfix for hardcoded xlab 2. Use na.rm when determining axis limits for night shading to be compatible with plotting with some missing values --- R/plot.vpi.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/plot.vpi.R b/R/plot.vpi.R index 7486cc86..4d5e70ec 100644 --- a/R/plot.vpi.R +++ b/R/plot.vpi.R @@ -116,7 +116,7 @@ plot.vpi <- function(x, quantity = "mtr", xlab = "time", # plot the data plot(x$datetime, x[quantity][[1]], - type = "l", xlab = "time", ylab = ylab, + type = "l", xlab = xlab, ylab = ylab, ylim = ylim, main = main, xaxs = "i", yaxs = "i", ... ) @@ -145,8 +145,8 @@ plot.vpi <- function(x, quantity = "mtr", xlab = "time", # determine the plot range of the night time shading if (missing(ylim)) { pol.range <- c( - min(c(0, 2 * min(x[quantity][[1]]))), - 2 * max(x[quantity][[1]]) + min(c(0, 2 * min(x[quantity][[1]], na.rm = TRUE))), + 2 * max(x[quantity][[1]], na.rm = TRUE) ) } else { pol.range <- ylim @@ -167,7 +167,7 @@ plot.vpi <- function(x, quantity = "mtr", xlab = "time", # plot the data again on top of the shading graphics::points(x$datetime, x[quantity][[1]], type = "l", - xlab = "time", ylab = ylab, ylim = ylim, main = main, ... + xlab = xlab, ylab = ylab, ylim = ylim, main = main, ... ) } }