getSVGMappings: Retrieving Viewport, Grob, and Reference Names as SVG IDs,...

View source: R/mapping.R

Retrieve Names Mapped to SVG IDs, CSS Selectors and XPath ExpressionsR Documentation

Retrieving Viewport, Grob, and Reference Names as SVG IDs, CSS Selectors and XPath Expressions


This function gives us SVG IDs (or CSS selectors and XPath expressions) that have been created from a grob, viewport, or referenced name as a result of exporting to SVG.


getSVGMappings(name, type, result = "id")



A single element character vector. This should be the name of a grob or viewport (as determined by type) present as the grid plot was exported.


A single element character vector, must be one of vp, grob or ref. This determines whether we are trying to get the IDs of a grob or a viewport or a referenced object like a fill pattern.


The type of output we want. id gives us SVG element IDs. selector gives us CSS selectors. xpath gives us XPath expressions.


In order to generate unique names for SVG IDs, gridSVG output will not produce the same names as are visible on the grid display list. This function retrieves the SVG IDs associated with grob and viewport names. To use this function first requires importing mapping information, see gridSVGMappings.

To make using results easier with existing JavaScript libraries and R packages, CSS selectors and XPath expressions can be returned. This is the case when result is specified as one of selector or xpath. These are targeted to match just the SVG element itself, nothing more.


A character vector representing values that can target specific SVG output.


Simon Potter

gridSVG documentation built on March 31, 2023, 11:17 p.m.