Skip to contents

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

Usage

register_svg_shape(name, svg_source)

Arguments

name

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

svg_source

Character: path to SVG file OR inline SVG string.

Value

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

Examples

# Register a custom SVG shape from an inline SVG string
register_svg_shape("simple_star",
  '<svg viewBox="0 0 100 100">
    <polygon points="50,5 20,99 95,39 5,39 80,99" fill="currentColor"/>
  </svg>')

# 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")
#> Cograph Network
#> ==============
#> Nodes: 3 
#> Edges: 4 
#> Directed: TRUE 
#> Weighted: FALSE 
#> Layout: computed 
#> Theme: classic 
#> 
#> Use plot() or sn_render() to visualize
#> Use sn_ggplot() to convert to ggplot2