Commit c5fbbe8c authored by unknown's avatar unknown
Browse files

v0.1.1.7 plot.CalGR function has new xlab, ylab and main default values

parent 4914dfab
Package: airGRteaching Package: airGRteaching
Type: Package Type: Package
Title: Tools to Simplify the Use of the airGR Hydrological Package for Education (including a Shiny Application) Title: Tools to Simplify the Use of the airGR Hydrological Package for Education (including a Shiny Application)
Version: 0.1.1.6 Version: 0.1.1.7
Date: 2017-02-16 Date: 2017-02-16
Authors@R: c(person("Olivier", "Delaigue", role = c("aut", "cre"), email = "airGR@irstea.fr"), person("Laurent", "Coron", role = c("aut")), person("Pierre", "Brigode", role = c("aut"))) Authors@R: c(person("Olivier", "Delaigue", role = c("aut", "cre"), email = "airGR@irstea.fr"), person("Laurent", "Coron", role = c("aut")), person("Pierre", "Brigode", role = c("aut")))
Depends: airGR (>= 1.0.5.4) Depends: airGR (>= 1.0.5.4)
......
plot.CalGR <- function(x, which = c("perf", "hist", "time"), ...) { plot.CalGR <- function(x, xlab = NULL, ylab = NULL, main = NULL, which = c("perf", "hist", "time"), ...) {
if (! any(class(x) %in% "CalGR")) { if (! any(class(x) %in% "CalGR")) {
stop("Non convenient data for x argument. Must be of class \"CalGR\"") stop("Non convenient data for x argument. Must be of class \"CalGR\"")
...@@ -53,6 +53,17 @@ plot.CalGR <- function(x, which = c("perf", "hist", "time"), ...) { ...@@ -53,6 +53,17 @@ plot.CalGR <- function(x, which = c("perf", "hist", "time"), ...) {
} }
if (any(which[1L] %in% c("time"))) { if (any(which[1L] %in% c("time"))) {
if (is.null(xlab)) {
xlab <- "Time"
}
if (is.null(ylab)) {
yunit <- .TypeModelGR(x)$TimeUnit
ylab <- paste0(c("flow [mm/", "precip. [mm/"), yunit, "]")
} else {
if (length(ylab) < 2) {
ylab <- c(ylab, "")
}
}
data <- data.frame(DatesR = x$OutputsModel$DatesR, data <- data.frame(DatesR = x$OutputsModel$DatesR,
Precip = x$OutputsModel$Precip, Precip = x$OutputsModel$Precip,
Qobs = x$Qobs, Qobs = x$Qobs,
...@@ -60,11 +71,11 @@ plot.CalGR <- function(x, which = c("perf", "hist", "time"), ...) { ...@@ -60,11 +71,11 @@ plot.CalGR <- function(x, which = c("perf", "hist", "time"), ...) {
par(mar = c(0.1, 4, 4, 1), xaxt = "n") par(mar = c(0.1, 4, 4, 1), xaxt = "n")
plot(Precip ~ DatesR, data = data, type = "h", col = "royalblue", plot(Precip ~ DatesR, data = data, type = "h", col = "royalblue",
xlab = "", ylab = "Precip.", main = "", ylim = rev(range(data$Precip))) xlab = "", ylab = ylab[2L], main = main, ylim = rev(range(data$Precip)))
par(mar = c(5, 4, 0.1, 1), xaxt = "s") par(mar = c(5, 4, 0.1, 1), xaxt = "s")
matplot(data$DatesR, data[, c("Qobs", "Qsim")], type = "l", col = c("black", "orangered"), lty = 1, matplot(data$DatesR, data[, c("Qobs", "Qsim")], type = "l", col = c("black", "orangered"), lty = 1,
xlab = "Time", ylab = "Flow", main = "", xaxt = "n") xlab = xlab, ylab = ylab[1L], main = "", xaxt = "n")
axis.POSIXct(side = 1, x = data$DatesR) axis.POSIXct(side = 1, x = data$DatesR)
# if (plot.na) { # if (plot.na) {
......
...@@ -5,14 +5,20 @@ ...@@ -5,14 +5,20 @@
\usage{ \usage{
\method{plot}{CalGR}(x, which = c("perf", "hist", "time"), ...) \method{plot}{CalGR}(x, xlab = NULL, ylab = NULL, main = NULL,which = c("perf", "hist", "time"), ...)
} }
\arguments{ \arguments{
\item{x}{[object of class \emph{CalGR}] see \code{\link{CalGR}} for details} \item{x}{[object of class \emph{CalGR}] see \code{\link{CalGR}} for details}
\item{which}{[character] XXXX \code{"perf"}, \code{"hist"}, \code{"time"}}, \item{xlab}{(optional) [character] a label for the x axis: see \code{\link{title}}}
\item{ylab}{(optional) [character] a label for the y axis (flow and rainfall): see \code{\link{title}}}
\item{main}{(optional) [character] a main title for the plo: see \code{\link{title}}}
\item{which}{[character] XXXX \code{"perf"}, \code{"hist"}, \code{"time"}}
\item{...}{other parameters to be passed through to plotting functions} \item{...}{other parameters to be passed through to plotting functions}
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment