Definitions
Definitions are straightforward. They simply tell grapher to use a specific variable, as is, as visual aspect. grapher currently lets you define the following:
- Node color
- Node size
- Link source and target color
- Hidden links
g <- make_data() # mock data
head(g$nodes)
#> # A tibble: 100 x 4
#> id label size color
#> <chr> <chr> <dbl> <chr>
#> 1 1 A79 13 #12a2a8
#> 2 2 S19 23 #ffbf50
#> 3 3 A79 39 #8a60b0
#> 4 4 I61 28 #6f63bb
#> 5 5 D30 17 #2ca030
#> 6 6 D82 13 #ff7f0e
#> 7 7 W75 15 #c7519c
#> 8 8 K63 22 #2ca030
#> 9 9 W75 40 #bcbd22
#> 10 10 I61 15 #c7519c
#> # … with 90 more rows
The data generated by make_data
includes, amongst other variables, the column color
. However, you might have noticed that it is never used in our visualisation unless we explicitly scale_node_color
. Here we don't need to scale it, it's already a valid hex color. We simply want to apply it to the nodes.
graph(g) %>%
define_node_color(color)