Learn R Programming

cograph (version 1.5.2)

register_svg_shape: Register Custom SVG Shape

Description

Register an SVG file or string as a custom node shape.

Usage

register_svg_shape(name, svg_source)

Value

Invisible NULL. The shape is registered for use with sn_nodes().

Arguments

name

Character: unique name for this shape (used in node_shape parameter).

svg_source

Character: path to SVG file OR inline SVG string.

Examples

Run this code
# Register a custom SVG shape from an inline SVG string
register_svg_shape("simple_star",
  '
    
  ')

# Create a small adjacency matrix
adj <- matrix(c(0, 1, 1, 0, 0, 1, 1, 0, 0), nrow = 3,
              dimnames = list(c("A", "B", "C"), c("A", "B", "C")))

# Use in network (requires grImport2 for SVG rendering; falls back to circle)
cograph(adj) |> sn_nodes(shape = "simple_star")

Run the code above in your browser using DataLab