Skip to contents

See ugd_save() for saving rendered plots as files. This function will only work after starting a device with ugd().

Usage

ugd_render(
  page = 0,
  width = -1,
  height = -1,
  zoom = 1,
  as = "svg",
  which = dev.cur()
)

Arguments

page

Plot page to render. If this is set to 0, the last page will be selected. Can be set to a numeric plot index or plot ID (see ugd_id()).

width

Width of the plot. If this is set to -1, the last width will be selected.

height

Height of the plot. If this is set to -1, the last height will be selected.

zoom

Zoom level. (For example: 2 corresponds to 200%, 0.5 would be 50%.)

as

Renderer.

which

Which device (ID).

Value

Rendered plot. Text renderers return strings, binary renderers return byte arrays.

Examples

ugd()
plot(1, 1)
ugd_render(width = 600, height = 400, as = "svg")
#> [1] "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" class=\"httpgd\" width=\"600.00\" height=\"400.00\" viewBox=\"0 0 600.00 400.00\">\n<defs>\n  <style type='text/css'><![CDATA[\n    .httpgd line, .httpgd polyline, .httpgd polygon, .httpgd path, .httpgd rect, .httpgd circle {\n      fill: none;\n      stroke: #000000;\n      stroke-linecap: round;\n      stroke-linejoin: round;\n      stroke-miterlimit: 10.00;\n    }\n  ]]></style>\n<clipPath id=\"c0\"><rect x=\"0.00\" y=\"0.00\" width=\"600.00\" height=\"400.00\"/></clipPath>\n<clipPath id=\"c1\"><rect x=\"59.04\" y=\"59.04\" width=\"510.72\" height=\"267.52\"/></clipPath>\n<clipPath id=\"c2\"><rect x=\"0.00\" y=\"0.00\" width=\"600.00\" height=\"400.00\"/></clipPath>\n</defs>\n<rect width=\"100%\" height=\"100%\" style=\"stroke: none;fill: #FFFFFF;\"/>\n<g clip-path=\"url(#c0)\">\n</g><g clip-path=\"url(#c1)\">\n<circle cx=\"314.40\" cy=\"192.80\" r=\"2.70\" style=\"stroke-width: 0.75;\"/>\n</g><g clip-path=\"url(#c2)\">\n<line x1=\"77.96\" y1=\"326.56\" x2=\"550.84\" y2=\"326.56\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"77.96\" y1=\"326.56\" x2=\"77.96\" y2=\"333.76\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"196.18\" y1=\"326.56\" x2=\"196.18\" y2=\"333.76\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"314.40\" y1=\"326.56\" x2=\"314.40\" y2=\"333.76\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"432.62\" y1=\"326.56\" x2=\"432.62\" y2=\"333.76\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"550.84\" y1=\"326.56\" x2=\"550.84\" y2=\"333.76\" style=\"stroke-width: 0.75;\"/>\n<g><text x=\"77.96\" y=\"352.48\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">0.6</text></g>\n<g><text x=\"196.18\" y=\"352.48\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">0.8</text></g>\n<g><text x=\"314.40\" y=\"352.48\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">1.0</text></g>\n<g><text x=\"432.62\" y=\"352.48\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">1.2</text></g>\n<g><text x=\"550.84\" y=\"352.48\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">1.4</text></g>\n<line x1=\"59.04\" y1=\"316.65\" x2=\"59.04\" y2=\"68.95\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"59.04\" y1=\"316.65\" x2=\"51.84\" y2=\"316.65\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"59.04\" y1=\"254.73\" x2=\"51.84\" y2=\"254.73\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"59.04\" y1=\"192.80\" x2=\"51.84\" y2=\"192.80\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"59.04\" y1=\"130.87\" x2=\"51.84\" y2=\"130.87\" style=\"stroke-width: 0.75;\"/>\n<line x1=\"59.04\" y1=\"68.95\" x2=\"51.84\" y2=\"68.95\" style=\"stroke-width: 0.75;\"/>\n<g><text transform=\"translate(41.76,316.65) rotate(-90.00)\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">0.6</text></g>\n<g><text transform=\"translate(41.76,254.73) rotate(-90.00)\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">0.8</text></g>\n<g><text transform=\"translate(41.76,192.80) rotate(-90.00)\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">1.0</text></g>\n<g><text transform=\"translate(41.76,130.87) rotate(-90.00)\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">1.2</text></g>\n<g><text transform=\"translate(41.76,68.95) rotate(-90.00)\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"19.09px\" lengthAdjust=\"spacingAndGlyphs\">1.4</text></g>\n<polygon points=\"59.04,326.56 569.76,326.56 569.76,59.04 59.04,59.04\" style=\"stroke-width: 0.75;\" />\n<g><text x=\"314.40\" y=\"381.28\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"7.64px\" lengthAdjust=\"spacingAndGlyphs\">1</text></g>\n<g><text transform=\"translate(12.96,192.80) rotate(-90.00)\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"7.64px\" lengthAdjust=\"spacingAndGlyphs\">1</text></g>\n</g>\n</svg>"
dev.off()
#> agg_png 
#>       2