Skip to content

This is useful primarily for testing but can be used as an alternative to svgstring().

Usage

stringSVG(code, ...)

Arguments

code

Plotting code to execute.

...

Other arguments passed on to svglite.

Examples

stringSVG(plot(1:10))
#> Saving 7" x 7" image
#> <?xml version='1.0' encoding='UTF-8' ?>
#> <svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='504.00pt' height='504.00pt' viewBox='0 0 504.00 504.00'>
#> <g class='svglite'>
#> <defs>
#>   <style type='text/css'><![CDATA[
#>     .svglite line, .svglite polyline, .svglite polygon, .svglite path, .svglite rect, .svglite circle {
#>       fill: none;
#>       stroke: #000000;
#>       stroke-linecap: round;
#>       stroke-linejoin: round;
#>       stroke-miterlimit: 10.00;
#>     }
#>     .svglite text {
#>       white-space: pre;
#>     }
#>   ]]></style>
#> </defs>
#> <rect width='100%' height='100%' style='stroke: none; fill: #FFFFFF;'/>
#> <defs>
#>   <clipPath id='cpMC4wMHw1MDQuMDB8MC4wMHw1MDQuMDA='>
#>     <rect x='0.00' y='0.00' width='504.00' height='504.00' />
#>   </clipPath>
#> </defs>
#> <g clip-path='url(#cpMC4wMHw1MDQuMDB8MC4wMHw1MDQuMDA=)'>
#> </g>
#> <defs>
#>   <clipPath id='cpNTkuMDR8NDczLjc2fDU5LjA0fDQzMC41Ng=='>
#>     <rect x='59.04' y='59.04' width='414.72' height='371.52' />
#>   </clipPath>
#> </defs>
#> <g clip-path='url(#cpNTkuMDR8NDczLjc2fDU5LjA0fDQzMC41Ng==)'>
#> <circle cx='74.40' cy='416.80' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='117.07' cy='378.58' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='159.73' cy='340.36' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='202.40' cy='302.13' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='245.07' cy='263.91' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='287.73' cy='225.69' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='330.40' cy='187.47' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='373.07' cy='149.24' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='415.73' cy='111.02' r='2.70' style='stroke-width: 0.75;' />
#> <circle cx='458.40' cy='72.80' r='2.70' style='stroke-width: 0.75;' />
#> </g>
#> <g clip-path='url(#cpMC4wMHw1MDQuMDB8MC4wMHw1MDQuMDA=)'>
#> <line x1='117.07' y1='430.56' x2='458.40' y2='430.56' style='stroke-width: 0.75;' />
#> <line x1='117.07' y1='430.56' x2='117.07' y2='437.76' style='stroke-width: 0.75;' />
#> <line x1='202.40' y1='430.56' x2='202.40' y2='437.76' style='stroke-width: 0.75;' />
#> <line x1='287.73' y1='430.56' x2='287.73' y2='437.76' style='stroke-width: 0.75;' />
#> <line x1='373.07' y1='430.56' x2='373.07' y2='437.76' style='stroke-width: 0.75;' />
#> <line x1='458.40' y1='430.56' x2='458.40' y2='437.76' style='stroke-width: 0.75;' />
#> <text x='117.07' y='456.48' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>2</text>
#> <text x='202.40' y='456.48' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>4</text>
#> <text x='287.73' y='456.48' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>6</text>
#> <text x='373.07' y='456.48' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>8</text>
#> <text x='458.40' y='456.48' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='15.28px' lengthAdjust='spacingAndGlyphs'>10</text>
#> <line x1='59.04' y1='378.58' x2='59.04' y2='72.80' style='stroke-width: 0.75;' />
#> <line x1='59.04' y1='378.58' x2='51.84' y2='378.58' style='stroke-width: 0.75;' />
#> <line x1='59.04' y1='302.13' x2='51.84' y2='302.13' style='stroke-width: 0.75;' />
#> <line x1='59.04' y1='225.69' x2='51.84' y2='225.69' style='stroke-width: 0.75;' />
#> <line x1='59.04' y1='149.24' x2='51.84' y2='149.24' style='stroke-width: 0.75;' />
#> <line x1='59.04' y1='72.80' x2='51.84' y2='72.80' style='stroke-width: 0.75;' />
#> <text transform='translate(41.76,378.58) rotate(-90)' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>2</text>
#> <text transform='translate(41.76,302.13) rotate(-90)' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>4</text>
#> <text transform='translate(41.76,225.69) rotate(-90)' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>6</text>
#> <text transform='translate(41.76,149.24) rotate(-90)' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='7.64px' lengthAdjust='spacingAndGlyphs'>8</text>
#> <text transform='translate(41.76,72.80) rotate(-90)' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='15.28px' lengthAdjust='spacingAndGlyphs'>10</text>
#> <polygon points='59.04,430.56 473.76,430.56 473.76,59.04 59.04,59.04 ' style='stroke-width: 0.75;' />
#> <text x='266.40' y='485.28' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='33.06px' lengthAdjust='spacingAndGlyphs'>Index</text>
#> <text transform='translate(12.96,244.80) rotate(-90)' text-anchor='middle' style='font-size: 12.00px; font-family: "Liberation Sans";' textLength='26.96px' lengthAdjust='spacingAndGlyphs'>1:10</text>
#> </g>
#> </g>
#> </svg>