knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(mcbrnet) library(tidyverse)
ggbrnet()
is a wrapper of ggraph
functions for easy visualization of a network produced by brnet()
.
ggbrnet()
takes brnet()
object as the first argument, so it's compatible with pipe %>%
:
brnet() %>% ggbrnet()
Arguments: patch_color
Users can change how they color patches by specifying patch_color
. Default is "black"
. Other options are env
and disturb
referring to the environment
and disturbance
columns, respectively:
set.seed(1)
## colored by `environment` brnet() %>% ggbrnet(patch_color = "env") + # "environment" works too labs(color = "Environment") ## colored by `disturbance` brnet() %>% ggbrnet(patch_color = "disturb") + # "disturbance" works too labs(color = "Disturbance")
It is also possible to specify one of the columns in .$df_patch
:
df0 <- brnet() df0$df_patch <- df0$df_patch %>% mutate(x = runif(50, 0, 100)) df0 %>% ggbrnet(patch_color = "x") + labs(color = "x")
If patch_color
is neither env
, disturb
, nor any column in .$df_patch
, the function takes it as an ordinary color name, for example:
set.seed(1)
brnet() %>% ggbrnet()
Arguments: patch_label
Users may add patch labels using the argument patch_label
:
set.seed(1)
# patch ID brnet() %>% ggbrnet(patch_label = "patch")
set.seed(1)
# branch ID brnet() %>% ggbrnet(patch_label = "branch")
set.seed(1)
# number of upstream contributing patches brnet() %>% ggbrnet(patch_label = "n_upstream")
Users may specify additional arguments passed to ggraph::geom_node_label()
to tweak details, for example:
# branch ID adjust label position brnet() %>% ggbrnet(nudge_x = 0.2)
To change patch size, specify patch_size
:
set.seed(1)
brnet() %>% ggbrnet(patch_size = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.