Skip to contents

Query unigd graphics device static plot IDs. Available plot IDs starting from index will be returned. limit specifies the number of plots. This function will only work after starting a device with ugd().

Usage

ugd_id(index = 0, limit = 1, which = dev.cur(), state = FALSE)

Arguments

index

Plot index. If this is set to 0, the last page will be selected.

limit

Limit the number of returned IDs. If this is set to a value > 1 the returned type is a list if IDs. Set to 0 for all.

which

Which device (ID).

state

Include the current device state in the returned result (see also: ugd_state()).

Value

List containing static plot IDs.

Examples

ugd() # Initialize graphics device

# Page 1
plot.new()
text(.5, .5, "#1")

# Page 2
plot.new()
text(.5, .5, "#2")

# Page 3
plot.new()
text(.5, .5, "#3")

third <- ugd_id() # Get ID of page 3 (last page)
second <- ugd_id(2) # Get ID of page 2
all <- ugd_id(1, limit = Inf) # Get all IDs

ugd_remove(1) # Remove page 1
#> [1] TRUE
ugd_render(second) # Render page 2
#> 1unigd 
#>     3 
#> [1] "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" class=\"httpgd\" width=\"720.00\" height=\"576.00\" viewBox=\"0 0 720.00 576.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=\"720.00\" height=\"576.00\"/></clipPath>\n<clipPath id=\"c1\"><rect x=\"59.04\" y=\"59.04\" width=\"630.72\" height=\"443.52\"/></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<g><text x=\"374.40\" y=\"285.25\" text-anchor=\"middle\" style=\"font-family: Liberation Sans;font-size: 12.00px;\" textLength=\"17.70px\" lengthAdjust=\"spacingAndGlyphs\">#2</text></g>\n</g>\n</svg>"

dev.off() # Close device
#> agg_png 
#>       2