Skip to content

Commit

Permalink
1. Bugfix for hardcoded xlab
Browse files Browse the repository at this point in the history
2. Use na.rm when determining axis limits for night shading to be
   compatible with plotting with some missing values
  • Loading branch information
dsheldon committed Jan 14, 2025
1 parent ec53dc1 commit 11d84f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions R/plot.vpi.R
Original file line number Diff line number Diff line change
Expand Up @@ -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", ...
)

Expand Down Expand Up @@ -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
Expand All @@ -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, ...
)
}
}

0 comments on commit 11d84f1

Please sign in to comment.