Skip to contents

Convenience function for quick inline plot rendering. This is similar to ugd_render() but the plotting code is specified inline and an unigd graphics device is managed (created and closed) automatically. Starting a device with ugd() is therefore not necessary.

Usage

ugd_render_inline(
  code,
  page = 0,
  width = getOption("unigd.width", 720),
  height = getOption("unigd.height", 576),
  zoom = 1,
  as = "svg",
  ...
)

Arguments

code

Plotting code. See examples for more information.

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.

height

Height of the plot.

zoom

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

as

Renderer.

...

Additional parameters passed to ugd(...)

Value

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

Examples

ugd_render_inline({
  hist(rnorm(100))
}, as = "svgz")
#>    [1] 1f 8b 08 00 00 00 00 00 00 03 cd 58 5b 6f 9b 48 14 7e cf af 98 25 5a 35
#>   [25] 91 e2 61 2e 5c 1d 63 29 bb 55 bb 0f 7d 58 69 f7 ad ea 03 05 8c 69 31 78
#>   [49] 81 c4 76 57 fb df 7b 66 86 8b af d4 61 9b c8 8e e4 c0 37 c3 77 ee 87 33
#>   [73] 9e 94 4f 31 5a 2f d2 ac f4 b4 79 55 2d c7 ba be 5a ad f0 8a e3 bc 88 75
#>   [97] 46 08 d1 61 87 a6 b6 8c d7 69 92 7d 3d b6 91 ba ae ab cb 55 0d 05 a9 5f
#>  [121] d6 6c 71 a8 a1 55 12 56 73 4f b3 19 c1 84 68 68 1e 25 f1 bc f2 34 d3 b6
#>  [145] e4 fd 53 12 ad 7e cb d7 9e 46 10 41 6a 13 aa d7 a6 57 93 30 9a 95 d3 2b
#>  [169] 84 26 65 b5 49 23 54 6d 96 91 f7 a6 8a d6 95 1e 94 e5 9b e9 e4 97 8f bf
#>  [193] bf 7d f8 fb e1 23 6c 41 08 2b 91 08 d4 88 ee da bb 65 9e 6e 0e 91 38 cf
#>  [217] b6 00 bf 9a 77 77 45 14 54 dd 5d 90 14 01 48 fe 57 4a 40 68 96 a4 e9 18
#>  [241] 65 79 16 dd d7 48 59 15 f9 d7 68 8c ae 89 fc ec c2 23 21 39 f0 97 63 54
#>  [265] e4 8f 59 78 64 f1 4b 9e 64 c7 57 17 49 15 15 69 02 ff c6 88 0a bf a8 f5
#>  [289] ff e0 fb d3 a7 e9 44 97 2e 01 1f 05 69 b2 fc 13 2c 40 49 e8 69 01 b8 6d
#>  [313] 22 2c 40 c2 a5 d2 c3 9b e6 a2 3f 12 3a 50 36 54 07 ac 74 8b d5 74 31 31
#>  [337] 24 6d 7d 55 f3 5a 9c 60 9b 75 bc 86 c1 b1 c9 f6 79 75 15 52 c5 56 3f 49
#>  [361] 09 f9 b5 7b 4e dd 49 eb 3c ad f1 ae f4 b8 72 fe f5 3b f9 b9 07 e6 ab 49
#>  [385] 8c 04 f7 48 44 d0 d3 1e 8b f4 e6 3a 20 b7 22 73 e2 e9 44 e4 89 50 98 db
#>  [409] 06 36 94 23 b8 81 6d 5b 43 62 65 e4 67 c1 3c 2f 3c 6d 91 84 61 1a b5 12
#>  [433] 67 79 56 8d 66 fe 22 49 37 63 f4 21 f9 1c 15 7e 95 e4 19 fa cb cf ca 7b
#>  [457] b9 58 26 df 40 23 2a 48 97 6b 05 ad a4 ee 63 f4 39 4f c3 7b c5 ff 21 ca
#>  [481] 62 a1 14 23 1c 53 be 5c 6b 28 95 c8 43 f8 e5 b1 04 33 cb a5 1f 24 59 fc
#>  [505] 90 85 ef d3 cd 72 5e 6a d3 3f 92 b2 ca e3 c2 5f a0 7c 86 8a 2c 2f 16 37
#>  [529] e0 8b db 89 2e e8 c0 8b f1 49 b3 4c d3 c6 cc f9 49 76 31 c8 06 b0 6b d7
#>  [553] 0a cb c1 dc 3e c7 88 1f e8 5d 15 20 6e 06 5b 3c 4d 5e a6 7e 15 dd 80 48
#>  [577] d7 ba 63 0e c1 0e b9 85 5a a8 04 38 72 45 9a de be a8 51 80 b2 73 8c 7a
#>  [601] 57 44 ff 3c 46 59 b0 d9 b1 49 94 2f 5a 53 4f 73 98 0a 04 5c 9a 84 61 d3
#>  [625] 82 7e c9 80 9e 72 cc 29 e0 ac c3 77 d2 7a 24 f3 7f 8c a0 6e 4c 95 ce 3f
#>  [649] a2 6c 60 c9 e8 62 fb 19 8c d4 71 b0 e9 1c 52 b6 f8 00 4e e6 1a 72 ff 3e
#>  [673] 67 8b 0f e0 34 08 c1 ae 79 c8 d9 e2 03 38 4d 62 43 0d 1e 72 b6 f8 00 ce
#>  [697] 36 ba bd 51 3f 8b 73 ab a8 9b 00 c3 b3 cc c1 c6 8b d6 34 a5 d8 3d ab a6
#>  [721] 47 fc 54 0f 6a 93 e7 b2 f4 65 a7 f4 6d 13 f3 b2 f4 a5 a7 f4 6d 93 fe 35
#>  [745] f4 b5 b1 65 9c a3 2e 39 a5 6d 5b 4e 97 a4 ed 49 df b6 85 7a 49 da b2 e3
#>  [769] 6f 98 66 e6 12 fd d1 b1 a4 93 65 ff aa 61 b8 b4 4d 6c d8 cf e8 88 27 08
#>  [793] 29 76 6a c2 06 1e c0 c8 1d 2e 95 d9 63 6c e0 01 8c 6a 36 38 60 6c e0 01
#>  [817] 8c d4 76 8e 59 dd c0 03 18 eb 08 ec 11 9e 17 97 de f1 c8 a0 d0 b3 ee 54
#>  [841] 3c 5e 73 3c fa 7f fd a0 c7 14 95 08 97 68 8a f9 5c 53 5e 7f 68 a5 26 8c
#>  [865] fa 67 35 be 67 c7 45 25 ff 65 1a f3 ec c8 c8 c2 bb 48 5b d8 6e 60 e0 eb
#>  [889] d8 31 96 ca 63 6c 73 e8 ee e6 42 c3 32 b1 d5 9d e6 4d 8e 89 db 1d 9e e1
#>  [913] 6c 6f f6 b6 af fa 0c fd 96 8b 3f d5 7c 1a 19 94 83 cb 5c 25 84 19 92 e7
#>  [937] b8 10 8b 4a 0d 86 09 e9 26 c6 e6 7d 70 5c 08 85 99 da ea ed 9c 3d 52 18
#>  [961] e4 80 78 18 a4 30 8b 60 76 52 0a 63 26 76 06 4b e9 a6 49 d7 da fe 89 65
#>  [985] 4f 08 87 e4 eb 7f a9 f4 08 e1 86 8d 1d 35 02 d6 ef 92 e3 42 0c 4a 86 fb
#> [1009] 6b 6b ce 7c 41 7f 19 a6 d1 fc 74 44 4d bb 27 8b 39 cc 63 83 d3 78 6b 0a
#> [1033] e5 8c 4a 6d 4f 64 98 65 48 4b 87 49 11 6e 62 2f 9d c7 5b 33 ea cf af 7b
#> [1057] d5 7d ca a7 78 fa 1d d4 3d 20 b3 06 16 00 00

s <- ugd_render_inline({
  plot.new()
  lines(c(0.5, 1, 0.5), c(0.5, 1, 1))
})
cat(s)
#> <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">
#> <defs>
#>   <style type='text/css'><![CDATA[
#>     .httpgd line, .httpgd polyline, .httpgd polygon, .httpgd path, .httpgd rect, .httpgd circle {
#>       fill: none;
#>       stroke: #000000;
#>       stroke-linecap: round;
#>       stroke-linejoin: round;
#>       stroke-miterlimit: 10.00;
#>     }
#>   ]]></style>
#> <clipPath id="c0"><rect x="0.00" y="0.00" width="720.00" height="576.00"/></clipPath>
#> <clipPath id="c1"><rect x="59.04" y="59.04" width="630.72" height="443.52"/></clipPath>
#> </defs>
#> <rect width="100%" height="100%" style="stroke: none;fill: #FFFFFF;"/>
#> <g clip-path="url(#c0)">
#> </g><g clip-path="url(#c1)">
#> <polyline points="374.40,280.80 666.40,75.47 374.40,75.47" style="stroke-width: 0.75;"/>
#> </g>
#> </svg>