Main plotting function for Cograph networks. Renders the network visualization using grid graphics. Accepts all node and edge aesthetic parameters.
soplot(
network,
title = NULL,
title_size = 14,
margins = c(0.05, 0.05, 0.1, 0.05),
layout_margin = 0.15,
newpage = TRUE,
layout = NULL,
theme = NULL,
seed = 42,
labels = NULL,
threshold = NULL,
maximum = NULL,
node_size = NULL,
node_shape = NULL,
node_fill = NULL,
node_border_color = NULL,
node_border_width = NULL,
node_alpha = NULL,
label_size = NULL,
label_color = NULL,
label_position = NULL,
show_labels = NULL,
pie_values = NULL,
pie_colors = NULL,
pie_border_width = NULL,
donut_values = NULL,
donut_border_width = NULL,
donut_inner_ratio = NULL,
donut_bg_color = NULL,
donut_show_value = NULL,
donut_value_size = NULL,
donut_value_color = NULL,
donut_fill = NULL,
donut_color = NULL,
donut_colors = NULL,
donut_shape = "circle",
donut_value_fontface = "bold",
donut_value_fontfamily = "sans",
donut_value_digits = 2,
donut_value_prefix = "",
donut_value_suffix = "",
donut2_values = NULL,
donut2_colors = NULL,
donut2_inner_ratio = 0.4,
edge_width = NULL,
edge_size = NULL,
esize = NULL,
edge_width_range = NULL,
edge_scale_mode = "linear",
edge_cutoff = NULL,
cut = NULL,
edge_width_scale = NULL,
edge_color = NULL,
edge_alpha = NULL,
edge_style = NULL,
curvature = NULL,
arrow_size = NULL,
show_arrows = NULL,
edge_positive_color = NULL,
positive_color = NULL,
edge_negative_color = NULL,
negative_color = NULL,
edge_duplicates = NULL,
edge_labels = NULL,
edge_label_size = NULL,
edge_label_color = NULL,
edge_label_position = NULL,
edge_label_offset = NULL,
edge_label_bg = NULL,
edge_label_fontface = NULL,
edge_label_border = NULL,
edge_label_border_color = NULL,
edge_label_underline = NULL,
bidirectional = NULL,
loop_rotation = NULL,
curve_shape = NULL,
curve_pivot = NULL,
curves = NULL,
node_names = NULL,
legend = FALSE,
legend_position = "topright",
scaling = "default",
weight_digits = 2
)sn_render(
network,
title = NULL,
title_size = 14,
margins = c(0.05, 0.05, 0.1, 0.05),
layout_margin = 0.15,
newpage = TRUE,
layout = NULL,
theme = NULL,
seed = 42,
labels = NULL,
threshold = NULL,
maximum = NULL,
node_size = NULL,
node_shape = NULL,
node_fill = NULL,
node_border_color = NULL,
node_border_width = NULL,
node_alpha = NULL,
label_size = NULL,
label_color = NULL,
label_position = NULL,
show_labels = NULL,
pie_values = NULL,
pie_colors = NULL,
pie_border_width = NULL,
donut_values = NULL,
donut_border_width = NULL,
donut_inner_ratio = NULL,
donut_bg_color = NULL,
donut_show_value = NULL,
donut_value_size = NULL,
donut_value_color = NULL,
donut_fill = NULL,
donut_color = NULL,
donut_colors = NULL,
donut_shape = "circle",
donut_value_fontface = "bold",
donut_value_fontfamily = "sans",
donut_value_digits = 2,
donut_value_prefix = "",
donut_value_suffix = "",
donut2_values = NULL,
donut2_colors = NULL,
donut2_inner_ratio = 0.4,
edge_width = NULL,
edge_size = NULL,
esize = NULL,
edge_width_range = NULL,
edge_scale_mode = "linear",
edge_cutoff = NULL,
cut = NULL,
edge_width_scale = NULL,
edge_color = NULL,
edge_alpha = NULL,
edge_style = NULL,
curvature = NULL,
arrow_size = NULL,
show_arrows = NULL,
edge_positive_color = NULL,
positive_color = NULL,
edge_negative_color = NULL,
negative_color = NULL,
edge_duplicates = NULL,
edge_labels = NULL,
edge_label_size = NULL,
edge_label_color = NULL,
edge_label_position = NULL,
edge_label_offset = NULL,
edge_label_bg = NULL,
edge_label_fontface = NULL,
edge_label_border = NULL,
edge_label_border_color = NULL,
edge_label_underline = NULL,
bidirectional = NULL,
loop_rotation = NULL,
curve_shape = NULL,
curve_pivot = NULL,
curves = NULL,
node_names = NULL,
legend = FALSE,
legend_position = "topright",
scaling = "default",
weight_digits = 2
)
Invisible NULL. Called for side effect of drawing.
A cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted.
Optional plot title.
Title font size.
Plot margins as c(bottom, left, top, right).
Margin around the network layout (proportion of viewport). Default 0.15.
Logical. Start a new graphics page? Default TRUE.
Layout algorithm. Built-in: "circle", "spring", "groups", "grid", "random", "star", "bipartite". igraph (2-letter): "kk" (Kamada-Kawai), "fr" (Fruchterman-Reingold), "drl", "mds", "ni" (nicely), "tr" (tree), etc. Can also pass a coordinate matrix or igraph layout function directly.
Theme name: "classic", "dark", "minimal", etc.
Random seed for deterministic layouts. Default 42. Set NULL for random.
Node labels. Can be a character vector to set custom labels.
Minimum absolute edge weight to display. Edges with abs(weight) < threshold are hidden. Similar to qgraph's threshold.
Maximum edge weight for width scaling. Weights above this are capped. Similar to qgraph's maximum parameter.
Node size.
Node shape: "circle", "square", "triangle", "diamond", "ellipse", "heart", "star", "pie", "donut", "cross".
Node fill color.
Node border color.
Node border width.
Node transparency (0-1).
Node label text size.
Node label text color.
Label position: "center", "above", "below", "left", "right".
Logical. Show node labels?
For pie/donut/donut_pie nodes: list or matrix of values for segments. For donut with single value (0-1), shows that proportion filled.
For pie/donut/donut_pie nodes: colors for pie segments.
Border width for pie chart segments.
For donut_pie nodes: vector of values (0-1) for outer ring proportion.
Border width for donut ring.
For donut nodes: inner radius ratio (0-1). Default 0.5.
For donut nodes: background color for unfilled portion.
For donut nodes: show value in center? Default FALSE.
For donut nodes: font size for center value.
For donut nodes: color for center value text.
Numeric value (0-1) for donut fill proportion. This is the simplified API for creating donut charts. Can be a single value or vector per node.
Fill color(s) for the donut ring. Simplified API: single color for fill, or c(fill, background) for both.
Deprecated. Use donut_color instead.
Base shape for donut: "circle", "square", "hexagon", "triangle", "diamond", "pentagon". Default inherits from node_shape.
Font face for donut center value: "plain", "bold", "italic", "bold.italic". Default "bold".
Font family for donut center value. Default "sans".
Decimal places for donut center value. Default 2.
Text before donut center value (e.g., "$"). Default "".
Text after donut center value (e.g., "%"). Default "".
List of values for inner donut ring (for double donut).
List of color vectors for inner donut ring segments.
Inner radius ratio for inner donut ring. Default 0.4.
Edge width. If NULL, scales by weight using edge_size and edge_width_range.
Base edge size for weight scaling. NULL (default) uses adaptive sizing
based on network size: 15 * exp(-n_nodes/90) + 1. Larger values = thicker edges.
Deprecated. Use edge_size instead.
Output width range as c(min, max) for weight-based scaling. Default c(0.5, 4). Edges are scaled to fit within this range.
Scaling mode for edge weights: "linear" (default), "log" (for wide weight ranges), "sqrt" (moderate compression), or "rank" (equal visual spacing).
Two-tier cutoff for edge width scaling. NULL (default) = auto 75th percentile. 0 = disabled. Positive number = manual threshold.
Deprecated. Use edge_cutoff instead.
Scale factor for edge widths. Values > 1 make edges thicker.
Edge color.
Edge transparency (0-1).
Line style: "solid", "dashed", "dotted".
Edge curvature amount.
Size of arrow heads.
Logical. Show arrows?
Color for positive edge weights.
Deprecated. Use edge_positive_color instead.
Color for negative edge weights.
Deprecated. Use edge_negative_color instead.
How to handle duplicate edges in undirected networks. NULL (default) = stop with error listing duplicates. Options: "sum", "mean", "first", "max", "min", or a custom aggregation function.
Edge labels. Can be TRUE to show weights, or a vector.
Edge label text size.
Edge label text color.
Position along edge (0 = source, 0.5 = middle, 1 = target).
Perpendicular offset from edge line.
Background color for edge labels (default "white"). Set to NA for transparent.
Font face: "plain", "bold", "italic", "bold.italic".
Border style: NULL, "rect", "rounded", "circle".
Border color for label border.
Logical. Underline the label text?
Logical. Show arrows at both ends of edges?
Angle in radians for self-loop direction (default: pi/2 = top).
Spline tension for curved edges (-1 to 1, default: 0).
Pivot position along edge for curve control point (0-1, default: 0.5).
Curve mode: TRUE (default) = single edges straight, reciprocal edges curve as ellipse (two opposing curves); FALSE = all straight; "force" = all curved.
Alternative names for legend (separate from display labels).
Logical. Show legend?
Legend position: "topright", "topleft", "bottomright", "bottomleft".
Scaling mode: "default" for qgraph-matched scaling where node_size=6 looks similar to qgraph vsize=6, or "legacy" to preserve pre-v2.0 behavior.
Number of decimal places to round edge weights to before plotting. Edges that round to zero are automatically removed. Default 2. Set NULL to disable rounding.
soplot() uses grid graphics while splot() uses base R graphics.
Both accept the same parameters and produce visually similar output. Choose based on:
soplot: Better for integration with ggplot2, combining plots, and publication-quality vector graphics.
splot: Better for large networks (faster rendering), interactive exploration, and traditional R workflows.
Edge curving is controlled by the curves and curvature parameters:
All edges are straight lines.
(Default) Reciprocal edge pairs (A->B and
B->A) curve in opposite directions to form a visual ellipse. Single
edges remain straight.
All edges curve inward toward the network center.
Controls how edge weights map to visual widths:
Width proportional to weight. Best for similar-magnitude weights.
Logarithmic scaling. Best for weights spanning orders of magnitude.
Square root scaling. Moderate compression for skewed data.
Rank-based scaling. Equal visual spacing regardless of values.
The donut system visualizes proportions (0-1) as filled rings around nodes:
Proportion filled (0-1). Can be scalar or per-node vector.
Fill color. Single color, c(fill, bg), or per-node vector.
Base shape: "circle", "square", "hexagon", etc.
Show numeric value in center.
splot for base R graphics rendering (alternative engine),
cograph for creating network objects,
sn_nodes for node customization,
sn_edges for edge customization,
sn_layout for layout algorithms,
sn_theme for visual themes,
from_qgraph and from_tna for converting external objects
adj <- matrix(c(0, 1, 1, 1, 0, 1, 1, 1, 0), nrow = 3)
# With cograph()
cograph(adj) |> soplot()
# Direct matrix input with all options
adj |> soplot(
layout = "circle",
node_fill = "steelblue",
node_size = 0.08,
edge_width = 2
)
Run the code above in your browser using DataLab