A function to plot a graph with nodes and edges.
GraphPlot(
node,
edge,
transition = NULL,
node_coord = c("x", "y"),
node_group = NULL,
node_palette = "Chinese",
node_palcolor = NULL,
node_size = 4,
node_alpha = 1,
node_highlight = NULL,
node_highlight_color = "red",
label = FALSE,
label.size = 3.5,
label.fg = "white",
label.bg = "black",
label.bg.r = 0.1,
label_insitu = FALSE,
label_repel = FALSE,
label_repulsion = 20,
label_point_size = 1,
label_point_color = "black",
label_segment_color = "black",
edge_threshold = 0.01,
use_triangular = c("upper", "lower", "both"),
edge_line = c("straight", "curved"),
edge_line_curvature = 0.3,
edge_line_angle = 90,
edge_color = "grey30",
edge_size = c(0.2, 1),
edge_alpha = 0.5,
edge_shorten = 0,
edge_offset = 0,
edge_highlight = NULL,
edge_highlight_color = "red",
transition_threshold = 0.01,
transition_line = c("straight", "curved"),
transition_line_curvature = 0.3,
transition_line_angle = 90,
transition_color = "black",
transition_size = c(0.2, 1),
transition_alpha = 1,
transition_arrow_type = "closed",
transition_arrow_angle = 20,
transition_arrow_length = grid::unit(0.02, "npc"),
transition_shorten = 0.05,
transition_offset = 0,
transition_highlight = NULL,
transition_highlight_color = "red",
aspect.ratio = 1,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
legend.position = "right",
legend.direction = "vertical",
theme_use = "theme_this",
theme_args = list(),
return_layer = FALSE
)A data frame representing the nodes of the graph.
A matrix representing the edges of the graph.
A matrix representing the transitions between nodes.
A character vector specifying the names of the columns in node that represent the x and y coordinates.
A character vector specifying the name of the column in node that represents the grouping of the nodes.
A character vector specifying the name of the color palette for node groups.
A character vector specifying the names of the colors for each node group.
A numeric value or column name of node specifying the size of the nodes.
A numeric value or column name of node specifying the transparency of the nodes.
A character vector specifying the names of nodes to highlight.
A character vector specifying the color for highlighting nodes.
Whether to show labels for the nodes.
The size of the labels.
A character vector specifying the foreground color of the labels.
A character vector specifying the background color of the labels.
The background color transparency of the labels.
Whether to display the node group labels in situ or as numeric values.
Whether to use force-directed label repulsion.
The repulsion force for labels.
The size of the label points.
A character vector specifying the color of the label points.
A character vector specifying the color for the label segments.
The threshold for removing edges.
A character vector specifying which part of the edge matrix to use (upper, lower, both).
A character vector specifying the type of line for edges (straight, curved).
The curvature of curved edges.
The angle of curved edges.
A character vector specifying the color of the edges.
A numeric vector specifying the range of edge sizes.
The transparency of the edges.
The length of the edge shorten.
The length of the edge offset.
A character vector specifying the names of edges to highlight.
A character vector specifying the color for highlighting edges.
The threshold for removing transitions.
A character vector specifying the type of line for transitions (straight, curved).
The curvature of curved transitions.
The angle of curved transitions.
A character vector specifying the color of the transitions.
A numeric vector specifying the range of transition sizes.
The transparency of the transitions.
A character vector specifying the type of arrow for transitions (closed, open).
The angle of the transition arrow.
The length of the transition arrow.
The length of the transition shorten.
The length of the transition offset.
A character vector specifying the names of transitions to highlight.
A character vector specifying the color for highlighting transitions.
Aspect ratio passed to theme().
Plot title.
Plot subtitle.
Label for the x axis.
Label for the y axis.
Legend position passed to theme().
Legend direction passed to theme().
Theme function applied to the plot.
A named list of arguments passed to theme_use.
Whether to return the plot layers as a list.
Defaults is FALSE.
node <- data.frame(
x = c(0.2, 0.3, 0.5, 0.3),
y = c(0.2, 0, 0.6, 0.7),
group = c("A", "B", "C", "B"),
row.names = c("n1", "n2", "n3", "n4")
)
edge <- matrix(
c(
0, 0.4, 0.2, 0.1,
0.4, 0, 0.3, 0.2,
0.2, 0.3, 0 , 0.5,
0.2, 0.2, 0.5, 0.3
),
nrow = 4,
byrow = TRUE,
dimnames = list(rownames(node), rownames(node))
)
GraphPlot(
node = node,
edge = edge
)
GraphPlot(
node = node,
edge = edge,
node_group = "group",
node_highlight = "n1",
label = TRUE,
label_repel = TRUE
)
Run the code above in your browser using DataLab