Customize the visual appearance of edges in a network plot.
sn_edges(
network,
width = NULL,
edge_size = NULL,
esize = NULL,
edge_width_range = NULL,
edge_scale_mode = NULL,
edge_cutoff = NULL,
cut = NULL,
color = NULL,
edge_positive_color = NULL,
positive_color = NULL,
edge_negative_color = NULL,
negative_color = NULL,
alpha = NULL,
style = NULL,
curvature = NULL,
arrow_size = NULL,
show_arrows = NULL,
maximum = NULL,
width_scale = NULL,
labels = NULL,
label_size = NULL,
label_color = NULL,
label_position = NULL,
label_offset = NULL,
label_bg = NULL,
label_bg_padding = NULL,
label_fontface = NULL,
label_border = NULL,
label_border_color = NULL,
label_underline = NULL,
label_shadow = NULL,
label_shadow_color = NULL,
label_shadow_offset = NULL,
label_shadow_alpha = NULL,
bidirectional = NULL,
loop_rotation = NULL,
curve_shape = NULL,
curve_pivot = NULL,
curves = NULL,
ci = NULL,
ci_scale = NULL,
ci_alpha = NULL,
ci_color = NULL,
ci_style = NULL,
ci_arrows = NULL,
ci_lower = NULL,
ci_upper = NULL,
label_style = NULL,
label_template = NULL,
label_digits = NULL,
label_ci_format = NULL,
label_p = NULL,
label_p_digits = NULL,
label_p_prefix = NULL,
label_stars = NULL
)Modified cograph_network object that can be piped to further customization functions or plotting functions.
A cograph_network object, matrix, data.frame, or igraph object. Matrices and other inputs are auto-converted.
Edge width. Can be a single value, vector (per-edge), or "weight".
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.
Edge color. Can be a single color, vector, or "weight" for automatic coloring based on edge weights.
Color for positive edge weights.
Deprecated. Use edge_positive_color instead.
Color for negative edge weights.
Deprecated. Use edge_negative_color instead.
Edge transparency (0-1).
Line style: "solid", "dashed", "dotted", "longdash", "twodash".
Edge curvature amount (0 = straight).
Size of arrow heads for directed networks.
Logical. Show arrows? Default TRUE for directed networks.
Maximum edge weight for scaling width. Weights above this are capped. Similar to qgraph's maximum parameter.
Scale factor for edge widths. Values > 1 make edges thicker, values < 1 make them thinner. Applied after all other width calculations.
Edge labels. Can be TRUE (show weights), a vector, or column name.
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.
Padding around label text as proportion of text size (default 0.3).
Font face: "plain", "bold", "italic", "bold.italic" (default "plain").
Border style: NULL (none), "rect", "rounded", "circle" (default NULL).
Border color for label border (default "gray50").
Logical. Underline the label text? (default FALSE).
Logical. Enable drop shadow for labels? (default FALSE).
Color for label shadow (default "gray40").
Offset distance for shadow in points (default 0.5).
Transparency for shadow (0-1, default 0.5).
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: FALSE (straight edges), "mutual" (only curve reciprocal pairs), or "force" (curve all edges). Default FALSE.
Numeric vector of CI widths (0-1 scale). Larger values = more uncertainty.
Width multiplier for CI underlay thickness. Default 2.
Transparency for CI underlay (0-1). Default 0.15.
CI underlay color. NA (default) uses main edge color.
Line type for CI underlay: 1=solid, 2=dashed, 3=dotted. Default 2.
Logical: show arrows on CI underlay? Default FALSE.
Numeric vector of lower CI bounds for labels.
Numeric vector of upper CI bounds for labels.
Preset style: "none", "estimate", "full", "range", "stars".
Template with placeholders: {est}, {range}, {low}, {up}, {p}, {stars}.
Decimal places for estimates in template. Default 2.
CI format: "bracket" for [low, up] or "dash" for low-up.
Numeric vector of p-values for edges.
Decimal places for p-values. Default 3.
Prefix for p-values. Default "p=".
Stars for labels: character vector, TRUE (compute from p), or numeric (treated as p-values).
Most aesthetic parameters can be specified as:
Single value: Applied to all edges
Vector: Per-edge values (must match edge count)
"weight": Special value for width and color that
auto-maps from edge weights
When color = "weight", edges are colored by sign:
Positive weights use edge_positive_color (default: green)
Negative weights use edge_negative_color (default: red)
When width = "weight", edge widths scale with absolute weight values,
respecting the maximum parameter if set.
For statistical output (e.g., regression coefficients with CIs), use templates:
label_template = "\{est\}": Show estimate only
label_template = "\{est\} [\{low\}, \{up\}]": Estimate with CI
label_template = "\{est\}\{stars\}": Estimate with significance
Preset styles via label_style:
"estimate": Weight/estimate only
"full": Estimate + CI in brackets
"range": CI range only
"stars": Significance stars
Visualize uncertainty by drawing a wider, semi-transparent edge behind:
ci: Vector of CI widths (0-1 scale)
ci_scale: Width multiplier (default 2)
ci_alpha: Transparency (default 0.15)
sn_nodes for node customization,
cograph for network creation,
splot and soplot for plotting,
sn_layout for layout algorithms,
sn_theme for visual themes
adj <- matrix(c(0, 1, -0.5, 1, 0, 1, -0.5, 1, 0), nrow = 3)
# Basic: auto-style by weight
cograph(adj) |>
sn_edges(width = "weight", color = "weight")
# Direct matrix input (auto-converted)
adj |> sn_edges(width = 2, color = "gray50")
# Custom positive/negative colors
cograph(adj) |>
sn_edges(
color = "weight",
edge_positive_color = "darkblue",
edge_negative_color = "darkred"
) |>
splot()
# Edge labels showing weights
cograph(adj) |>
sn_edges(labels = TRUE, label_size = 0.8) |>
splot()
# Statistical output with CI template
# Suppose we have estimates, lower/upper CI bounds
estimates <- c(0.5, -0.3, 0.8)
ci_lo <- c(0.2, -0.6, 0.5)
ci_hi <- c(0.8, -0.1, 1.1)
cograph(adj) |>
sn_edges(
label_template = "{est} [{low}, {up}]",
ci_lower = ci_lo,
ci_upper = ci_hi,
label_digits = 2
) |>
splot()
# Curved edges for reciprocal pairs
cograph(adj) |>
sn_edges(curves = "mutual", curvature = 0.3) |>
splot()
Run the code above in your browser using DataLab