An error occurred while loading the file. Please try again.
-
Dorchies David authored
Refs #42
fbb87832
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
% 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)
}