Learn R Programming

svgedit

svgedit allows creating figures with complex layout programmatically in R, by using an SVG file as a template.

Installation

You can install svgedit from CRAN with:

install.packages("svgedit")

Workflow

There are four main steps to use svgedit:

  1. Create an SVG template file using the Inkscape graphics editor
  2. Create your figure layout in the SVG file, including:
    • Rectangles for ggplot2 plots and images (they will be replaced by your plots and images)
    • Text elements containing the {} placeholder for dynamic text (a single text box can contain multiple {} placeholders)
    • Any "static" elements you like (text, images, shapes...)
  3. Open Inkscape's "Layers and Objects" (Ctrl + Shift + L), and click on your placeholder elements to set their labels
  4. In R, use svgedit to replace the placeholders with your plots, images, and text

Example

See the package vignette by running vignette("multi-panel-figure", package = "svgedit") for an example use.

Copy Link

Version

Install

install.packages('svgedit')

Version

1.0.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Daniel Thedie

Last Published

December 11th, 2025

Functions in svgedit (1.0.0)

get_doc_unit

Get the unit used in the SVG document
insert_svg

Add an element to an SVG document, replacing a target element
unit_to_inch

Convert a measurement to inches based on the unit
insert_text

Replace "" in a text element by provided values
find_element

Find an element by label in an Inkscape SVG document
get_element_dimensions

Get the dimensions of an SVG element
draw

Replace an svg object by a ggplot2 graph
svgedit-package

svgedit: Insert Graphs, Images and Text in SVG Files
insert_image

Insert a raster image (PNG/JPG) into an SVG document, replacing a target element