diff --git a/CHANGELOG.md b/CHANGELOG.md index 05771725396..d0da88b9738 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,9 @@ For more information about this file see also [Keep a Changelog](http://keepacha ### Changed - Rebuilt documentation using Roxygen 7. Readers get nicer formatting of usage sections, writers get more flexible behavior when inheriting parameters and less hassle when maintaining namespaces (#2524). -- PEcAn.priors: renamed functions that looked like S3 methods but were not: `plot.posterior.density`->`plot_posterior.density`, `plot.prior.density`->`plot_prior.density`, `plot.trait`->`plot_trait` (#2439). +- Renamed functions that looked like S3 methods but were not: + * PEcAn.priors: `plot.posterior.density`->`plot_posterior.density`, `plot.prior.density`->`plot_prior.density`, `plot.trait`->`plot_trait` (#2439). + * PEcAn.visualization: `plot.netcdf`->`plot_netcdf` (#2526). - Stricter package checking: `make check` and CI builds will now fail if `R CMD check` returns any ERRORs or any "newly-added" WARNINGs or NOTEs. "Newly-added" is determined by strict string comparison against a check result saved 2019-09-03; messages that exist in the reference result do not break the build but will be fixed as time allows in future refactorings (#2404). - No longer writing an arbitrary num for each PFT, this was breaking ED runs potentially. - The pecan/data container has no longer hardcoded path for postgres diff --git a/base/visualization/DESCRIPTION b/base/visualization/DESCRIPTION index 82969b68bc6..b7d1fe42245 100644 --- a/base/visualization/DESCRIPTION +++ b/base/visualization/DESCRIPTION @@ -22,12 +22,9 @@ Description: The Predictive Ecosystem Carbon Analyzer (PEcAn) is a scientific efficacy of scientific investigation. This module is used to create more complex visualizations from the data generated by PEcAn code, specifically the models. -Depends: - ggplot2, - raster, - sp Imports: data.table, + ggplot2, maps, ncdf4 (>= 1.15), PEcAn.DB, @@ -40,6 +37,8 @@ Imports: Suggests: grid, png, + raster, + sp, testthat (>= 1.0.2) License: BSD_3_clause + file LICENSE Copyright: Authors diff --git a/base/visualization/NAMESPACE b/base/visualization/NAMESPACE index d984107a7b6..de376be1ff5 100644 --- a/base/visualization/NAMESPACE +++ b/base/visualization/NAMESPACE @@ -4,5 +4,5 @@ export(add_icon) export(ciEnvelope) export(create_status_page) export(map.output) -export(plot.netcdf) +export(plot_netcdf) export(vwReg) diff --git a/base/visualization/R/ciEnvelope.R b/base/visualization/R/ciEnvelope.R index e19c60140c1..78e3932c1ac 100644 --- a/base/visualization/R/ciEnvelope.R +++ b/base/visualization/R/ciEnvelope.R @@ -3,7 +3,9 @@ #' @param x Vector defining CI center #' @param ylo Vector defining bottom of CI envelope #' @param yhi Vector defining top of CI envelope -#' @export +#' @param ... further arguments passed on to `graphics::polygon` +#' +#' @export #' @author Michael Dietze, David LeBauer ciEnvelope <- function(x, ylo, yhi, ...) { m <- rbind(x, ylo, yhi) @@ -30,6 +32,7 @@ ciEnvelope <- function(x, ylo, yhi, ...) { x <- sub.m[[i]]["x", ] ylo <- sub.m[[i]]["ylo", ] yhi <- sub.m[[i]]["yhi", ] - polygon(cbind(c(x, rev(x), x[1]), c(ylo, rev(yhi), ylo[1])), border = NA, ...) + graphics::polygon( + cbind(c(x, rev(x), x[1]), c(ylo, rev(yhi), ylo[1])), border = NA, ...) } } # ciEnvelope diff --git a/base/visualization/R/create_status_page.R b/base/visualization/R/create_status_page.R index 9e4dd2fbfe3..b7f6df3180f 100644 --- a/base/visualization/R/create_status_page.R +++ b/base/visualization/R/create_status_page.R @@ -95,7 +95,7 @@ create_status_page <- function(config_file, file_prefix='status', delta=3600) { lastdump <- 0 # never dumped if(RCurl::url.exists(version_url)) { temporaryFile <- tempfile() - download.file(version_url, destfile = temporaryFile, quiet = TRUE) + utils::download.file(version_url, destfile = temporaryFile, quiet = TRUE) version <- scan(temporaryFile,what = "character", sep = "\t", quiet = TRUE) unlink(temporaryFile) @@ -113,8 +113,8 @@ create_status_page <- function(config_file, file_prefix='status', delta=3600) { # check if the schema has been updated, if so log the event if ((hostname %in% nodes) && (nodes[[hostname]]['schema'] != schema)) { msg <- paste(Sys.time(), "SCHEMA UPDATE DETECTED ON NODE", x$sync_host_id, hostname, - "FROM", nodeinfo[[hostname]]['schema'], "TO", schema) - write(msg, file=paste0(file_prefix, ".log"), append=TRUE) + "FROM", nodes[[hostname]]['schema'], "TO", schema) + write(msg, file = paste0(file_prefix, ".log"), append = TRUE) } } } @@ -124,7 +124,7 @@ create_status_page <- function(config_file, file_prefix='status', delta=3600) { sync <- list() if (RCurl::url.exists(log_url)) { temporaryFile <- tempfile() - download.file(log_url, destfile = temporaryFile, quiet = TRUE) + utils::download.file(log_url, destfile = temporaryFile, quiet = TRUE) log <- scan(temporaryFile,what = "character", sep = "\n", quiet = TRUE) unlink(temporaryFile) @@ -176,30 +176,38 @@ create_status_page <- function(config_file, file_prefix='status', delta=3600) { save(geoinfo, schema_versions, nodes, file=paste0(file_prefix, ".RData")) ## create image - png(filename=paste0(file_prefix, ".png"), width=1200) - xlim <- extendrange(sapply(nodes, function(x) { x$lon }), f=1) - ylim <- extendrange(sapply(nodes, function(x) { x$lat }), f=1) - maps::map("world", xlim=xlim, ylim=ylim) - maps::map("state",add=TRUE) + grDevices::png(filename = paste0(file_prefix, ".png"), width = 1200) + xlim <- grDevices::extendrange(sapply(nodes, function(x) { x$lon }), f = 1) + ylim <- grDevices::extendrange(sapply(nodes, function(x) { x$lat }), f = 1) + maps::map("world", xlim = xlim, ylim = ylim) + maps::map("state", add = TRUE) # show all edges edgecolors <- c("green","red", "yellow") x <- lapply(nodes, function(x) { lapply(x$sync, function(y) { - segments((x$lon+nodes[[y$id]]$lon)/2, ( x$lat+nodes[[y$id]]$lat)/2, x$lon, x$lat, col=edgecolors[y$status+1], lwd=2) + graphics::segments( + (x$lon + nodes[[y$id]]$lon) / 2, + (x$lat + nodes[[y$id]]$lat) / 2, + x$lon, + x$lat, + col = edgecolors[y$status + 1], lwd = 2) }) }) # show all pecan sites - nodecolors <- c("green","yellow", "red") + nodecolors <- c("green", "yellow", "red") x <- lapply(nodes, function(x) { - points(x$lon, x$lat, col=nodecolors[x$state+1], pch=19, cex=3) - text(x$lon, x$lat, labels=x$sync_host_id) + graphics::points( + x$lon, x$lat, + col = nodecolors[x$state + 1], + pch = 19, cex = 3) + graphics::text(x$lon, x$lat, labels = x$sync_host_id) }) # graph done - text(xlim[1], ylim[1], labels = Sys.time(), pos=4) - dev.off() + graphics::text(xlim[1], ylim[1], labels = Sys.time(), pos = 4) + grDevices::dev.off() ## create html file htmltable <- '' diff --git a/base/visualization/R/map.output.R b/base/visualization/R/map.output.R index d0cbb76d228..53acfb44ad9 100644 --- a/base/visualization/R/map.output.R +++ b/base/visualization/R/map.output.R @@ -7,16 +7,24 @@ #' @author David LeBauer map.output <- function(table, variable) { if (any(table$lat < 0) | any(table$lon > 0)) { - world <- data.table::data.table(map_data("world")) + world <- data.table::data.table(ggplot2::map_data("world")) } else { - world <- data.table::data.table(map_data("usa")) + world <- data.table::data.table(ggplot2::map_data("usa")) } - map <- ggplot() + - geom_polygon(data = world, aes(x = long, y = lat, group = group), fill = "white", color = "darkgrey") + - geom_point(data = table, aes(x = lon, y = lat, color = table[, variable]), size = 5) + - scale_color_gradientn(colours = c("red", "orange", "yellow", "green", "blue", "violet")) + - theme_bw() + - xlim(range(pretty(table$lon))) + - ylim(range(pretty(table$lat))) + map <- ggplot2::ggplot() + + ggplot2::geom_polygon( + data = world, + ggplot2::aes(x = long, y = lat, group = group), + fill = "white", + color = "darkgrey") + + ggplot2::geom_point( + data = table, + ggplot2::aes(x = lon, y = lat, color = table[, variable]), + size = 5) + + ggplot2::scale_color_gradientn( + colours = c("red", "orange", "yellow", "green", "blue", "violet")) + + ggplot2::theme_bw() + + ggplot2::xlim(range(pretty(table$lon))) + + ggplot2::ylim(range(pretty(table$lat))) return(map) } # map.output diff --git a/base/visualization/R/plot.netcdf.R b/base/visualization/R/plot_netcdf.R similarity index 72% rename from base/visualization/R/plot.netcdf.R rename to base/visualization/R/plot_netcdf.R index e0eb68ae5fd..827f3748549 100644 --- a/base/visualization/R/plot.netcdf.R +++ b/base/visualization/R/plot_netcdf.R @@ -33,7 +33,7 @@ data.fetch <- function(var, nc, fun = mean) { # aggregate the data data <- ncdf4::ncvar_get(nc, var) - val <- aggregate(data[indices], by = aggrlist, FUN = fun)$x + val <- stats::aggregate(data[indices], by = aggrlist, FUN = fun)$x # get the label title <- nc$var[[var]]$longname @@ -59,11 +59,10 @@ data.fetch <- function(var, nc, fun = mean) { ##' Load the tower dataset and create a plot. ##' -##' \code{plot.hdf5} loads the tower data from an HDF5 file generated by +##' Loads the tower data from an HDF5 file generated by ##' ED and will plot the values against one another. The default is for ##' the given variable to be plotted against time. ##' -##' @name plot.hdf5 ##' @param datafile the specific datafile to use. ##' @param yvar the variable to plot along the y-axis. ##' @param xvar the variable to plot along the x-axis, by default time is @@ -72,11 +71,13 @@ data.fetch <- function(var, nc, fun = mean) { ##' @param height the height of the image generated, default is 600 pixels. ##' @param filename is the name of the file name that is geneated, this ##' can be null to use existing device, otherwise it will try and -# @' create an image based on filename, or display if x11. +##' create an image based on filename, or display if x11. ##' @param year the year this data is for (only used in the title). +##' +##' @aliases plot.netcdf ##' @export ##' @author Rob Kooper -plot.netcdf <- function(datafile, yvar, xvar = "time", width = 800, height = 600, +plot_netcdf <- function(datafile, yvar, xvar = "time", width = 800, height = 600, filename = NULL, year = NULL) { # open netcdf file nc <- ncdf4::nc_open(datafile) @@ -90,33 +91,33 @@ plot.netcdf <- function(datafile, yvar, xvar = "time", width = 800, height = 600 # setup output if (!is.null(filename)) { if (tolower(filename) == "x11") { - x11(width = width / 96, height = height / 96) + grDevices::x11(width = width / 96, height = height / 96) } else if (tolower(stringr::str_sub(filename, -4)) == ".png") { - png(filename = filename, width = width, height = height) + grDevices::png(filename = filename, width = width, height = height) } else if (tolower(stringr::str_sub(filename, -4)) == ".pdf") { - pdf(filename = filename, width = width, height = height) + grDevices::pdf(file = filename, width = width, height = height) } else if (tolower(stringr::str_sub(filename, -4)) == ".jpg") { - jpg(filename = filename, width = width, height = height) + grDevices::jpeg(filename = filename, width = width, height = height) } else if (tolower(stringr::str_sub(filename, -5)) == ".tiff") { - tiff(filename = filename, width = width, height = height) + grDevices::tiff(filename = filename, width = width, height = height) } } # setup plot (needs to be done before removing of NA since that removes attr as well). - plot.new() - title(xlab = attr(xval_mean, "lbl")) - title(ylab = attr(yval_mean, "lbl")) + graphics::plot.new() + graphics::title(xlab = attr(xval_mean, "lbl")) + graphics::title(ylab = attr(yval_mean, "lbl")) if (xvar == "time") { if (is.null(year)) { - title(main = nc$var[[yvar]]$longname) + graphics::title(main = nc$var[[yvar]]$longname) } else { - title(main = paste(nc$var[[yvar]]$longname, "for", year)) + graphics::title(main = paste(nc$var[[yvar]]$longname, "for", year)) } } else { if (is.null(year)) { - title(main = paste(xvar, "VS", yvar)) + graphics::title(main = paste(xvar, "VS", yvar)) } else { - title(main = paste(xvar, "VS", yvar, "for", year)) + graphics::title(main = paste(xvar, "VS", yvar, "for", year)) } } # done with netcdf file @@ -139,29 +140,35 @@ plot.netcdf <- function(datafile, yvar, xvar = "time", width = 800, height = 600 o <- order(xval_mean, yval_mean) # plot actual data - plot.window(xlim = c(min(xval_mean), max(xval_mean)), + graphics::plot.window(xlim = c(min(xval_mean), max(xval_mean)), ylim = c(min(yvals), max(yvals))) - polygon(c(xval_mean[o], rev(xval_mean[o])), - c(yval_max[o], rev(yval_min[o])), - col = "gray", - border = "black") - lines(x = xval_mean[o], y = yval_mean[o], col = "red") - points(x = xval_mean[o], y = yval_mean[o], col = "black", pch = ".", cex = 5) - + graphics::polygon( + c(xval_mean[o], rev(xval_mean[o])), + c(yval_max[o], rev(yval_min[o])), + col = "gray", + border = "black") + graphics::lines(x = xval_mean[o], y = yval_mean[o], col = "red") + graphics::points( + x = xval_mean[o], + y = yval_mean[o], + col = "black", + pch = ".", + cex = 5) + # legend - legend("bottomright", col = c(1, "gray"), lwd = c(3, 6), - legend = c("mean", "min/max"), + graphics::legend("bottomright", col = c(1, "gray"), lwd = c(3, 6), + legend = c("mean", "min/max"), cex = 1.5) - + # draw axis and box - axis(1) - axis(2) - box() - + graphics::axis(1) + graphics::axis(2) + graphics::box() + ## add PEcAn icon add_icon() - + if (!is.null(filename) && (tolower(filename) != "x11")) { - dev.off() + grDevices::dev.off() } -} # plot.netcdf +} # plot_netcdf diff --git a/base/visualization/R/visually.weighted.watercolor.plots.R b/base/visualization/R/visually.weighted.watercolor.plots.R index 10d17107ed6..b0bfbf1938c 100644 --- a/base/visualization/R/visually.weighted.watercolor.plots.R +++ b/base/visualization/R/visually.weighted.watercolor.plots.R @@ -42,6 +42,10 @@ ##' \url{http://www.nicebread.de/visually-weighted-watercolor-plots-new-variants-please-vote/} ##' ##' @title PEcAn worldmap +##' +##' @param formula variables to plot. See examples +##' @param data data frame containing all variables used in formula +##' @param title passed on to ggplot ##' @param B = number bootstrapped smoothers ##' @param shade plot the shaded confidence region? ##' @param shade.alpha should the CI shading fade out at the edges? (by reducing alpha; 0 = no alpha decrease, 0.1 = medium alpha decrease, 0.5 = strong alpha decrease) @@ -84,15 +88,15 @@ vwReg <- function(formula, data, title = "", B = 1000, shade = TRUE, shade.alpha = 0.1, spag = FALSE, spag.color = "darkblue", mweight = TRUE, show.lm = FALSE, show.median = TRUE, median.col = "white", shape = 21, show.CI = FALSE, - method = loess, bw = FALSE, slices = 200, - palette = colorRampPalette(c("#FFEDA0", "#DD0000"), bias = 2)(20), + method = stats::loess, bw = FALSE, slices = 200, + palette = grDevices::colorRampPalette(c("#FFEDA0", "#DD0000"), bias = 2)(20), ylim = NULL, quantize = "continuous", add = FALSE, ...) { IV <- all.vars(formula)[2] DV <- all.vars(formula)[1] - data <- na.omit(data[order(data[, IV]), c(IV, DV)]) + data <- stats::na.omit(data[order(data[, IV]), c(IV, DV)]) if (bw) { - palette <- colorRampPalette(c("#EEEEEE", "#999999", "#333333"), bias = 2)(20) + palette <- grDevices::colorRampPalette(c("#EEEEEE", "#999999", "#333333"), bias = 2)(20) } print("Computing boostrapped smoothers ...") @@ -105,20 +109,27 @@ vwReg <- function(formula, data, title = "", B = 1000, shade = TRUE, shade.alpha data2 <- data[sample(nrow(data), replace = TRUE), ] data2 <- data2[order(data2[, IV]), ] if (inherits(l0, "loess")) { - m1 <- method(formula, data2, control = loess.control(surface = "i", - statistics = "a", - trace.hat = "a"), ...) + m1 <- method( + formula, + data2, + control = stats::loess.control( + surface = "i", + statistics = "a", + trace.hat = "a"), + ...) } else { m1 <- method(formula, data2, ...) } - l0.boot[, i] <- predict(m1, newdata = newx) + l0.boot[, i] <- stats::predict(m1, newdata = newx) } # compute median and CI limits of bootstrap CI.boot <- plyr::adply(l0.boot, 1, function(x) { - quantile(x, prob = c(0.025, 0.5, 0.975, - pnorm(c(-3, -2, -1, 0, 1, 2, 3))), - na.rm = TRUE) + stats::quantile( + x, + prob = c(0.025, 0.5, 0.975, + stats::pnorm(c(-3, -2, -1, 0, 1, 2, 3))), + na.rm = TRUE) })[, -1] colnames(CI.boot)[1:10] <- c("LL", "M", "UL", paste0("SD", 1:7)) CI.boot$x <- newx[, 1] @@ -137,7 +148,7 @@ vwReg <- function(formula, data, title = "", B = 1000, shade = TRUE, shade.alpha # an existing ggplot # if add == FALSE: provide the basic ggplot object - p0 <- ggplot(data, aes_string(x = IV, y = DV)) + theme_bw() + p0 <- ggplot2::ggplot(data, ggplot2::aes_string(x = IV, y = DV)) + ggplot2::theme_bw() # initialize elements with NULL (if they are defined, they are overwritten with something # meaningful) @@ -147,8 +158,8 @@ vwReg <- function(formula, data, title = "", B = 1000, shade = TRUE, shade.alpha quantize <- match.arg(quantize, c("continuous", "SD")) if (quantize == "continuous") { print("Computing density estimates for each vertical cut ...") - flush.console() - + utils::flush.console() + if (is.null(ylim)) { min_value <- min(min(l0.boot, na.rm = TRUE), min(data[, DV], na.rm = TRUE)) max_value <- max(max(l0.boot, na.rm = TRUE), max(data[, DV], na.rm = TRUE)) @@ -157,12 +168,12 @@ vwReg <- function(formula, data, title = "", B = 1000, shade = TRUE, shade.alpha # vertical cross-sectional density estimate d2 <- plyr::ddply(b2[, c("x", "value")], "x", function(df) { - res <- data.frame(density(df$value, + res <- data.frame(stats::density(df$value, na.rm = TRUE, n = slices, from = ylim[1], to = ylim[2])[c("x", "y")]) - # res <- data.frame(density(df$value, na.rm=TRUE, n=slices)[c('x', 'y')]) + # res <- data.frame(stats::density(df$value, na.rm=TRUE, n=slices)[c('x', 'y')]) colnames(res) <- c("y", "dens") return(res) }, .progress = "text") @@ -173,9 +184,12 @@ vwReg <- function(formula, data, title = "", B = 1000, shade = TRUE, shade.alpha ## Tile approach d2$alpha.factor <- d2$dens.scaled^shade.alpha - gg.tiles <- list(geom_tile(data = d2, aes(x = x, y = y, fill = dens.scaled, alpha = alpha.factor)), - scale_fill_gradientn("dens.scaled", colours = palette), - scale_alpha_continuous(range = c(0.001, 1))) + gg.tiles <- list( + ggplot2::geom_tile( + data = d2, + ggplot2::aes(x = x, y = y, fill = dens.scaled, alpha = alpha.factor)), + ggplot2::scale_fill_gradientn("dens.scaled", colours = palette), + ggplot2::scale_alpha_continuous(range = c(0.001, 1))) } if (quantize == "SD") { ## Polygon approach @@ -194,63 +208,67 @@ vwReg <- function(formula, data, title = "", B = 1000, shade = TRUE, shade.alpha d3 <- rbind(d3, seg) } - gg.poly <- list(geom_polygon(data = d3, - aes(x = x, y = value, color = NULL, fill = col, group = group)), - scale_fill_gradientn("dens.scaled", colours = palette, values = seq(-1, 3, 1))) + gg.poly <- list( + ggplot2::geom_polygon(data = d3, ggplot2::aes(x = x, y = value, color = NULL, fill = col, group = group)), + ggplot2::scale_fill_gradientn("dens.scaled", colours = palette, values = seq(-1, 3, 1))) } } print("Build ggplot figure ...") - flush.console() + utils::flush.console() if (spag) { - gg.spag <- geom_path(data = b2, - aes(x = x, y = value, group = B), - size = 0.7, - alpha = 10 / B, - color = spag.color) + gg.spag <- ggplot2::geom_path( + data = b2, + ggplot2::aes(x = x, y = value, group = B), + size = 0.7, + alpha = 10 / B, + color = spag.color) } if (show.median) { if (mweight) { - gg.median <- geom_path(data = CI.boot, - aes(x = x, y = M, alpha = w3 ^ 3), - size = 0.6, - linejoin = "mitre", - color = median.col) + gg.median <- ggplot2::geom_path( + data = CI.boot, + ggplot2::aes(x = x, y = M, alpha = w3 ^ 3), + size = 0.6, + linejoin = "mitre", + color = median.col) } else { - gg.median <- geom_path(data = CI.boot, - aes(x = x, y = M), - size = 0.6, - linejoin = "mitre", - color = median.col) + gg.median <- ggplot2::geom_path( + data = CI.boot, + ggplot2::aes(x = x, y = M), + size = 0.6, + linejoin = "mitre", + color = median.col) } } # Confidence limits if (show.CI) { - gg.CI1 <- geom_path(data = CI.boot, aes(x = x, y = UL), size = 1, color = "red") - gg.CI2 <- geom_path(data = CI.boot, aes(x = x, y = LL), size = 1, color = "red") + gg.CI1 <- ggplot2::geom_path(data = CI.boot, ggplot2::aes(x = x, y = UL), size = 1, color = "red") + gg.CI2 <- ggplot2::geom_path(data = CI.boot, ggplot2::aes(x = x, y = LL), size = 1, color = "red") } # plain linear regression line if (show.lm) { - gg.lm <- geom_smooth(method = "lm", color = "darkgreen", se = FALSE) + gg.lm <- ggplot2::geom_smooth(method = "lm", color = "darkgreen", se = FALSE) } - gg.points <- geom_point(data = data, - aes_string(x = IV, y = DV), - size = 1, - shape = shape, - fill = "white", - color = "black") + gg.points <- ggplot2::geom_point( + data = data, + ggplot2::aes_string(x = IV, y = DV), + size = 1, + shape = shape, + fill = "white", + color = "black") if (title != "") { - gg.title <- theme(title = title) + gg.title <- ggplot2::theme(title = title) } - gg.elements <- list(gg.tiles, gg.poly, gg.spag, gg.median, gg.CI1, gg.CI2, - gg.lm, gg.points, gg.title, theme(legend.position = "none")) + gg.elements <- list(gg.tiles, gg.poly, gg.spag, gg.median, gg.CI1, gg.CI2, + gg.lm, gg.points, gg.title, ggplot2::theme(legend.position = "none")) if (!add) { return(p0 + gg.elements) diff --git a/base/visualization/man/ciEnvelope.Rd b/base/visualization/man/ciEnvelope.Rd index 69f6aa0bc6a..afd7a5c92c3 100644 --- a/base/visualization/man/ciEnvelope.Rd +++ b/base/visualization/man/ciEnvelope.Rd @@ -12,6 +12,8 @@ ciEnvelope(x, ylo, yhi, ...) \item{ylo}{Vector defining bottom of CI envelope} \item{yhi}{Vector defining top of CI envelope} + +\item{...}{further arguments passed on to `graphics::polygon`} } \description{ plots a confidence interval around an x-y plot (e.g. a timeseries) diff --git a/base/visualization/man/plot.hdf5.Rd b/base/visualization/man/plot_netcdf.Rd similarity index 76% rename from base/visualization/man/plot.hdf5.Rd rename to base/visualization/man/plot_netcdf.Rd index ca88e23905f..391e5a34b68 100644 --- a/base/visualization/man/plot.hdf5.Rd +++ b/base/visualization/man/plot_netcdf.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.netcdf.R -\name{plot.hdf5} -\alias{plot.hdf5} +% Please edit documentation in R/plot_netcdf.R +\name{plot_netcdf} +\alias{plot_netcdf} \alias{plot.netcdf} \title{Load the tower dataset and create a plot.} \usage{ -plot.netcdf( +plot_netcdf( datafile, yvar, xvar = "time", @@ -28,12 +28,13 @@ used.} \item{height}{the height of the image generated, default is 600 pixels.} \item{filename}{is the name of the file name that is geneated, this -can be null to use existing device, otherwise it will try and} +can be null to use existing device, otherwise it will try and +create an image based on filename, or display if x11.} \item{year}{the year this data is for (only used in the title).} } \description{ -\code{plot.hdf5} loads the tower data from an HDF5 file generated by +Loads the tower data from an HDF5 file generated by ED and will plot the values against one another. The default is for the given variable to be plotted against time. } diff --git a/base/visualization/man/vwReg.Rd b/base/visualization/man/vwReg.Rd index 83b5160089e..c7d9649899a 100644 --- a/base/visualization/man/vwReg.Rd +++ b/base/visualization/man/vwReg.Rd @@ -19,10 +19,10 @@ vwReg( median.col = "white", shape = 21, show.CI = FALSE, - method = loess, + method = stats::loess, bw = FALSE, slices = 200, - palette = colorRampPalette(c("#FFEDA0", "#DD0000"), bias = 2)(20), + palette = (grDevices::colorRampPalette(c("#FFEDA0", "#DD0000"), bias = 2))(20), ylim = NULL, quantize = "continuous", add = FALSE, @@ -30,6 +30,12 @@ vwReg( ) } \arguments{ +\item{formula}{variables to plot. See examples} + +\item{data}{data frame containing all variables used in formula} + +\item{title}{passed on to ggplot} + \item{B}{= number bootstrapped smoothers} \item{shade}{plot the shaded confidence region?} diff --git a/base/visualization/tests/Rcheck_reference.log b/base/visualization/tests/Rcheck_reference.log index 88d69012a1d..4dd9386fe95 100644 --- a/base/visualization/tests/Rcheck_reference.log +++ b/base/visualization/tests/Rcheck_reference.log @@ -16,13 +16,7 @@ * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking serialization versions ... OK -* checking whether package ‘PEcAn.visualization’ can be installed ... WARNING -Found the following significant warnings: - Note: possible error in 'pdf(filename = filename, ': unused argument (filename = filename) -See ‘/tmp/RtmpP8kDnH/PEcAn.visualization.Rcheck/00install.out’ for details. -Information on the location(s) of code generating the ‘Note’s can be -obtained by re-running with environment variable R_KEEP_PKG_SOURCE set -to ‘yes’. +* checking whether package ‘PEcAn.visualization’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK * checking DESCRIPTION meta-information ... OK @@ -38,132 +32,27 @@ to ‘yes’. * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK -* checking dependencies in R code ... NOTE -Packages in Depends field not imported from: - ‘ggplot2’ ‘raster’ ‘sp’ - These packages need to be imported from (in the NAMESPACE file) - for when this namespace is loaded but not attached. -* checking S3 generic/method consistency ... WARNING -plot: - function(x, ...) -plot.netcdf: - function(datafile, yvar, xvar, width, height, filename, year) - -See section ‘Generic functions and methods’ in the ‘Writing R -Extensions’ manual. - -Found the following apparent S3 methods exported but not registered: - plot.netcdf -See section ‘Registering S3 methods’ in the ‘Writing R Extensions’ -manual. +* checking dependencies in R code ... OK +* checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... NOTE -Found an obsolete/platform-specific call in the following function: - ‘plot.netcdf’ -Found the platform-specific device: - ‘x11’ -dev.new() is the preferred way to open a new device, in the unlikely -event one is needed. -ciEnvelope: no visible global function definition for ‘polygon’ -create_status_page: no visible global function definition for - ‘download.file’ -create_status_page: no visible binding for global variable ‘nodeinfo’ -create_status_page: no visible global function definition for ‘png’ -create_status_page: no visible global function definition for - ‘extendrange’ -create_status_page : : : no visible global - function definition for ‘segments’ -create_status_page : : no visible global function definition - for ‘points’ -create_status_page : : no visible global function definition - for ‘text’ -create_status_page: no visible global function definition for ‘text’ -create_status_page: no visible global function definition for ‘dev.off’ -data.fetch: no visible global function definition for ‘aggregate’ -map.output: no visible global function definition for ‘map_data’ -map.output: no visible global function definition for ‘ggplot’ -map.output: no visible global function definition for ‘geom_polygon’ -map.output: no visible global function definition for ‘aes’ map.output: no visible binding for global variable ‘long’ map.output: no visible binding for global variable ‘lat’ map.output: no visible binding for global variable ‘group’ -map.output: no visible global function definition for ‘geom_point’ map.output: no visible binding for global variable ‘lon’ -map.output: no visible global function definition for - ‘scale_color_gradientn’ -map.output: no visible global function definition for ‘theme_bw’ -map.output: no visible global function definition for ‘xlim’ -map.output: no visible global function definition for ‘ylim’ -plot.netcdf: no visible global function definition for ‘x11’ -plot.netcdf: no visible global function definition for ‘png’ -plot.netcdf: no visible global function definition for ‘pdf’ -plot.netcdf: no visible global function definition for ‘jpg’ -plot.netcdf: no visible global function definition for ‘tiff’ -plot.netcdf: no visible global function definition for ‘plot.new’ -plot.netcdf: no visible global function definition for ‘title’ -plot.netcdf: no visible global function definition for ‘plot.window’ -plot.netcdf: no visible global function definition for ‘polygon’ -plot.netcdf: no visible global function definition for ‘lines’ -plot.netcdf: no visible global function definition for ‘points’ -plot.netcdf: no visible global function definition for ‘legend’ -plot.netcdf: no visible global function definition for ‘axis’ -plot.netcdf: no visible global function definition for ‘box’ -plot.netcdf: no visible global function definition for ‘dev.off’ -vwReg: no visible binding for global variable ‘loess’ -vwReg: no visible global function definition for ‘colorRampPalette’ -vwReg: no visible global function definition for ‘na.omit’ -vwReg: no visible global function definition for ‘loess.control’ -vwReg: no visible global function definition for ‘predict’ -vwReg : : no visible global function definition for - ‘quantile’ -vwReg : : no visible global function definition for ‘pnorm’ -vwReg: no visible global function definition for ‘ggplot’ -vwReg: no visible global function definition for ‘aes_string’ -vwReg: no visible global function definition for ‘theme_bw’ -vwReg: no visible global function definition for ‘flush.console’ -vwReg : : no visible global function definition for - ‘density’ -vwReg: no visible global function definition for ‘geom_tile’ -vwReg: no visible global function definition for ‘aes’ vwReg: no visible binding for global variable ‘x’ vwReg: no visible binding for global variable ‘y’ vwReg: no visible binding for global variable ‘dens.scaled’ vwReg: no visible binding for global variable ‘alpha.factor’ -vwReg: no visible global function definition for ‘scale_fill_gradientn’ -vwReg: no visible global function definition for - ‘scale_alpha_continuous’ -vwReg: no visible global function definition for ‘geom_polygon’ vwReg: no visible binding for global variable ‘value’ vwReg: no visible binding for global variable ‘group’ -vwReg: no visible global function definition for ‘geom_path’ vwReg: no visible binding for global variable ‘M’ vwReg: no visible binding for global variable ‘w3’ vwReg: no visible binding for global variable ‘UL’ vwReg: no visible binding for global variable ‘LL’ -vwReg: no visible global function definition for ‘geom_smooth’ -vwReg: no visible global function definition for ‘geom_point’ -vwReg: no visible global function definition for ‘theme’ Undefined global functions or variables: - aes aes_string aggregate alpha.factor axis box colorRampPalette - dens.scaled density dev.off download.file extendrange - flush.console geom_path geom_point geom_polygon geom_smooth geom_tile - ggplot grid.draw group jpg lat legend lines LL loess loess.control - lon long M map_data na.omit nodeinfo pdf plot.new plot.window png - pnorm points polygon predict quantile rasterGrob readPNG - scale_alpha_continuous scale_color_gradientn scale_fill_gradientn - segments text textGrob theme theme_bw tiff title UL unit value w3 x - x11 xlim y ylim -Consider adding - importFrom("graphics", "axis", "box", "legend", "lines", "plot.new", - "plot.window", "points", "polygon", "segments", "text", - "title") - importFrom("grDevices", "colorRampPalette", "dev.off", "extendrange", - "pdf", "png", "tiff", "x11") - importFrom("stats", "aggregate", "density", "loess", "loess.control", - "na.omit", "pnorm", "predict", "quantile") - importFrom("utils", "download.file", "flush.console") -to your NAMESPACE file. + alpha.factor dens.scaled group lat LL lon long M UL value w3 x y * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK @@ -175,32 +64,7 @@ All user-level objects in a package should have documentation entries. See chapter ‘Writing R documentation files’ in the ‘Writing R Extensions’ manual. * checking for code/documentation mismatches ... OK -* checking Rd \usage sections ... WARNING -Undocumented arguments in documentation object 'ciEnvelope' - ‘...’ - -Undocumented arguments in documentation object 'plot.hdf5' - ‘width’ ‘height’ -Duplicated \argument entries in documentation object 'plot.hdf5': - ‘the’ -Documented arguments not in \usage in documentation object 'plot.hdf5': - ‘the’ - -Undocumented arguments in documentation object 'vwReg' - ‘formula’ ‘data’ ‘title’ - -Functions with \usage entries need to have the appropriate \alias -entries, and all their arguments documented. -The \usage entries must correspond to syntactically valid R code. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. -S3 methods shown with full name in documentation object 'plot.hdf5': - ‘plot.netcdf’ - -The \usage entries for S3 methods should use the \method markup and not -their full name. -See chapter ‘Writing R documentation files’ in the ‘Writing R -Extensions’ manual. +* checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking contents of ‘data’ directory ... OK @@ -217,4 +81,4 @@ vwReg 11.31 0.1 11.486 * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... SKIPPED * DONE -Status: 5 WARNINGs, 2 NOTEs +Status: 2 WARNINGs, 1 NOTE diff --git a/web/plot.netcdf.R b/web/plot.netcdf.R index 8c56c291df0..6b0386d3eb4 100644 --- a/web/plot.netcdf.R +++ b/web/plot.netcdf.R @@ -31,5 +31,5 @@ filename <- args[7] # filename="plot.png" #error_reporting(E_ALL | E_STRICT); -PEcAn.visualization::plot.netcdf(datafile, yvar, xvar, width, height, filename, year); +PEcAn.visualization::plot_netcdf(datafile, yvar, xvar, width, height, filename, year);