diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index 3de30e984afe36fdd29b1ece13069d5f67abd1d1..9981ed3bd7fdd190f7151977b040da13ce7b8b2a 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -847,9 +847,19 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, col_inf_image <- ifelse(is.null(col_inf), colNA, col_inf) col_sup_image <- ifelse(is.null(col_sup), colNA, col_sup) if (square) { - image(lonb$x, latb$x, var[lonb$ix, latb$ix], col = c(col_inf_image, cols, col_sup_image), - breaks = c(-.Machine$double.xmax, brks, .Machine$double.xmax), - axes = FALSE, xlab = "", ylab = "", add = TRUE) + # If lat and lon are both regular-spaced, "useRaster = TRUE" can avoid + # artifact white lines on the figure. If not, useRaster has to be FALSE (default) + tryCatch({ + image(lonb$x, latb$x, var[lonb$ix, latb$ix], + col = c(col_inf_image, cols, col_sup_image), + breaks = c(-.Machine$double.xmax, brks, .Machine$double.xmax), + axes = FALSE, xlab = "", ylab = "", add = TRUE, useRaster = TRUE) + }, error = function(x) { + image(lonb$x, latb$x, var[lonb$ix, latb$ix], + col = c(col_inf_image, cols, col_sup_image), + breaks = c(-.Machine$double.xmax, brks, .Machine$double.xmax), + axes = FALSE, xlab = "", ylab = "", add = TRUE) + }) } else { .filled.contour(lonb$x, latb$x, var[lonb$ix, latb$ix], levels = c(.Machine$double.xmin, brks, .Machine$double.xmax),