Set global graph attributes

Share:

Description

Set global attributes of a specific type (either graph_attrs, node_attrs, or edge_attrs for a graph object of class dgr_graph).

Usage

1
set_global_graph_attrs(graph, type, attr_for_type, value)

Arguments

graph

a graph object of class dgr_graph that is created using create_graph.

type

the specific type of global graph attribute to set. The type is specified with graph, node, or edge.

attr_for_type

the name of the attribute to set for the type of global attribute specified.

value

the value to be set for the chosen attribute specified in the attr_for_type argument.

Value

a graph object of class dgr_graph.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
library(magrittr)

# Create a new graph and set some global attributes
graph <- create_graph() %>%
  set_global_graph_attrs(
    "graph", "overlap", "true") %>%
  set_global_graph_attrs(
    "node", "fontname", "Helvetica") %>%
  set_global_graph_attrs(
    "edge", "color", "gray")

# Verify that the global attributes have been set
get_global_graph_attrs(graph)
#> $graph_attrs
#> [1] "overlap = true"
#>
#> $node_attrs
#> [1] "fontname = Helvetica"
#>
#> $edge_attrs
#> [1] "color = gray"

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.