Skip to content

Commit 11d84f1

Browse files
committed
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
1 parent ec53dc1 commit 11d84f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

R/plot.vpi.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ plot.vpi <- function(x, quantity = "mtr", xlab = "time",
116116

117117
# plot the data
118118
plot(x$datetime, x[quantity][[1]],
119-
type = "l", xlab = "time", ylab = ylab,
119+
type = "l", xlab = xlab, ylab = ylab,
120120
ylim = ylim, main = main, xaxs = "i", yaxs = "i", ...
121121
)
122122

@@ -145,8 +145,8 @@ plot.vpi <- function(x, quantity = "mtr", xlab = "time",
145145
# determine the plot range of the night time shading
146146
if (missing(ylim)) {
147147
pol.range <- c(
148-
min(c(0, 2 * min(x[quantity][[1]]))),
149-
2 * max(x[quantity][[1]])
148+
min(c(0, 2 * min(x[quantity][[1]], na.rm = TRUE))),
149+
2 * max(x[quantity][[1]], na.rm = TRUE)
150150
)
151151
} else {
152152
pol.range <- ylim
@@ -167,7 +167,7 @@ plot.vpi <- function(x, quantity = "mtr", xlab = "time",
167167
# plot the data again on top of the shading
168168
graphics::points(x$datetime, x[quantity][[1]],
169169
type = "l",
170-
xlab = "time", ylab = ylab, ylim = ylim, main = main, ...
170+
xlab = xlab, ylab = ylab, ylim = ylim, main = main, ...
171171
)
172172
}
173173
}

0 commit comments

Comments
 (0)