plot_graph_lg {graph4lg} | R Documentation |
Plot graphs
Description
The function enables to plot graphs, whether spatial or not.
Usage
plot_graph_lg(
graph,
crds = NULL,
mode = "aspatial",
node_inter = NULL,
link_width = NULL,
node_size = NULL,
module = NULL,
pts_col = NULL
)
Arguments
graph |
A graph object of class |
crds |
(optional, default = NULL) If 'mode = 'spatial”, it is a
This argument is not used when 'mode = 'aspatial” and mandatory when 'mode = 'spatial”. |
mode |
A character string indicating whether the graph is spatial ('mode = 'spatial”) or not ('mode = 'aspatial” (default)) |
node_inter |
(optional, default = NULL) A character string indicating whether the links of the graph are weighted by distances or by similarity indices. It is only used when 'mode = 'aspatial” to compute the node positions with Fruchterman and Reingold algorithm. It can be equal to:
|
link_width |
(optional, default = NULL) A character string indicating how the width of the link is set on the figure. Their width can be:
|
node_size |
(optional, default = NULL) A character string indicating the graph node attribute used to set the node size on the figure. It must be the name of a numeric or integer node attribute from the graph. |
module |
(optional, default = NULL) A character string indicating the graph node modules used to set the node color on the figure. It must be the name of a node attribute from the graph with discrete values. |
pts_col |
(optional, default = NULL) A character string indicating the color used to plot the nodes (default: "#F2B950"). It must be a hexadecimal color code or a color used by default in R. It cannot be used if 'module' is specified. |
Details
When the graph is not spatial ('mode = 'aspatial”),
the nodes coordinates are calculated with Fruchterman et Reingold algorithm.
The graph object graph
of class igraph
must have node names
(not necessarily in the same order as IDs in crds, given a merging is done).
Value
A ggplot2 object to plot
Author(s)
P. Savary
References
Fruchterman TM, Reingold EM (1991). “Graph drawing by force-directed placement.” Software: Practice and experience, 21(11), 1129–1164.
Examples
data(pts_pop_ex)
data(data_ex_genind)
mat_w <- mat_gen_dist(data_ex_genind, dist = "DPS")
gp <- gen_graph_topo(mat_w = mat_w, topo = "mst")
g <- plot_graph_lg(graph = gp,
crds = pts_pop_ex,
mode = "spatial",
link_width = "inv_w")