plot.GRiwrm.Rd 3.30 KiB
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.GRiwrm.R
\name{plot.GRiwrm}
\alias{plot.GRiwrm}
\title{Display of a diagram representing the network structure of a GRiwrm object}
\usage{
\method{plot}{GRiwrm}(
  x,
  display = TRUE,
  orientation = "LR",
  width = "100\%",
  height = "100\%",
  box_colors = c(UpstreamUngauged = "#eef", UpstreamGauged = "#aaf", IntermUngauged =
    "#efe", IntermGauged = "#afa", DirectInjection = "#faa"),
  ...
)
}
\arguments{
\item{x}{[GRiwrm object] data to display. See \link{CreateGRiwrm} for details}

\item{display}{\link{logical} if \code{TRUE} displays the diagram with \link[DiagrammeR:mermaid]{DiagrammeR::mermaid}, returns the mermaid code otherwise}

\item{orientation}{\link{character} orientation of the graph. Possible values are "LR" (left-right), "RL" (right-left), "TB" (top-bottom), or "BT" (bottom-top). "LR" by default}

\item{width}{\link{numeric} width of the resulting graphic in pixels (See \link[DiagrammeR:mermaid]{DiagrammeR::mermaid})}

\item{height}{\link{numeric} height of the resulting graphic in pixels (See \link[DiagrammeR:mermaid]{DiagrammeR::mermaid})}

\item{box_colors}{\link{list} containing the color used for the different types of nodes}

\item{...}{Other arguments and parameters you would like to send to JavaScript (See \link[DiagrammeR:mermaid]{DiagrammeR::mermaid})}
}
\value{
Mermaid code of the diagram if display is \code{FALSE}, otherwise the function returns the diagram itself.
}
\description{
Display of a diagram representing the network structure of a GRiwrm object
}
\details{
This function only works inside RStudio because the HTMLwidget produced by DiagrammeR
is not handled on some platforms
}
\examples{
# Network of 2 nodes distant of 150 km:
# - an upstream reservoir modelled as a direct flow injection (no model)
# - a gauging station downstream a catchment of 360 km² modelled with GR4J
db <- data.frame(id = c("Reservoir", "GaugingDown"),
                 length = c(150, NA),
                 down = c("GaugingDown", NA),
                 area = c(NA, 360),
                 model = c(NA, "RunModel_GR4J"),
                 stringsAsFactors = FALSE)
griwrm_basic <- CreateGRiwrm(db)
griwrm_basic
# Network diagram with direct flow node in red, intermediate sub-basin in green
plot(griwrm_basic)

# GR4J semi-distributed model of the Severn River
data(Severn)
nodes <- Severn$BasinsInfo
nodes$model <- "RunModel_GR4J"
str(nodes)
# Mismatch column names are renamed to stick with GRiwrm requirements
rename_columns <- list(id = "gauge_id",
                       down = "downstream_id",
                       length = "distance_downstream")
griwrm_severn <- CreateGRiwrm(nodes, rename_columns)
griwrm_severn
# Network diagram with upstream basin nodes in blue, intermediate sub-basin in green
plot(griwrm_severn)

# Same model with an ungauged station at nodes 54029 and 54001
# By default the first gauged node at downstream is used for parameter calibration (54032)
nodes_ungauged <- nodes
nodes_ungauged$model[nodes_ungauged$gauge_id \%in\% c("54029", "54001")] <- "Ungauged"
griwrm_ungauged <- CreateGRiwrm(nodes_ungauged, rename_columns)
# The `donor` column define which node is used for parameter calibration
griwrm_ungauged
# Network diagram with gauged nodes of vivid color, and ungauged nodes of dull color
plot(griwrm_ungauged)
}