stringSVG: Run plotting code and return svg as string

Description Usage Arguments Examples

View source: R/inlineSVG.R

Description

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

Usage

1
stringSVG(code, ...)

Arguments

code

Plotting code to execute.

...

Other arguments passed on to svglite.

Examples

1
stringSVG(plot(1:10))

Example output

Saving 6.67" x 6.67" image
<?xml version='1.0' encoding='UTF-8' ?>
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 480.00 480.00'>
<defs>
  <style type='text/css'><![CDATA[
    line, polyline, path, rect, circle {
      fill: none;
      stroke: #000000;
      stroke-linecap: round;
      stroke-linejoin: round;
      stroke-miterlimit: 10.00;
    }
  ]]></style>
</defs>
<rect width='100%' height='100%' style='stroke: none; fill: #FFFFFF;'/>
<defs>
  <clipPath id='cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA=='>
    <rect x='59.04' y='59.04' width='390.72' height='347.52' />
  </clipPath>
</defs>
<circle cx='73.51' cy='393.69' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='113.71' cy='357.94' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='153.91' cy='322.18' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='194.10' cy='286.43' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='234.30' cy='250.68' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='274.50' cy='214.92' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='314.70' cy='179.17' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='354.89' cy='143.42' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='395.09' cy='107.66' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<circle cx='435.29' cy='71.91' r='2.70pt' style='stroke-width: 0.75;' clip-path='url(#cpNTkuMDR8NDQ5Ljc2fDQwNi41Nnw1OS4wNA==)' />
<defs>
  <clipPath id='cpMHw0ODB8NDgwfDA='>
    <rect x='0.00' y='0.00' width='480.00' height='480.00' />
  </clipPath>
</defs>
<line x1='113.71' y1='406.56' x2='435.29' y2='406.56' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='113.71' y1='406.56' x2='113.71' y2='413.76' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='194.10' y1='406.56' x2='194.10' y2='413.76' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='274.50' y1='406.56' x2='274.50' y2='413.76' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='354.89' y1='406.56' x2='354.89' y2='413.76' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='435.29' y1='406.56' x2='435.29' y2='413.76' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text x='110.37' y='432.48' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>2</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text x='190.77' y='432.48' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>4</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text x='271.16' y='432.48' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>6</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text x='351.56' y='432.48' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>8</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text x='428.62' y='432.48' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='13.35px' lengthAdjust='spacingAndGlyphs'>10</text></g>
<line x1='59.04' y1='357.94' x2='59.04' y2='71.91' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='59.04' y1='357.94' x2='51.84' y2='357.94' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='59.04' y1='286.43' x2='51.84' y2='286.43' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='59.04' y1='214.92' x2='51.84' y2='214.92' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='59.04' y1='143.42' x2='51.84' y2='143.42' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<line x1='59.04' y1='71.91' x2='51.84' y2='71.91' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text transform='translate(41.76,361.27) rotate(-90)' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>2</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text transform='translate(41.76,289.77) rotate(-90)' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>4</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text transform='translate(41.76,218.26) rotate(-90)' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>6</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text transform='translate(41.76,146.75) rotate(-90)' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='6.67px' lengthAdjust='spacingAndGlyphs'>8</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text transform='translate(41.76,78.58) rotate(-90)' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='13.35px' lengthAdjust='spacingAndGlyphs'>10</text></g>
<polyline points='59.04,406.56 449.76,406.56 449.76,59.04 59.04,59.04 59.04,406.56 ' style='stroke-width: 0.75;' clip-path='url(#cpMHw0ODB8NDgwfDA=)' />
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text x='239.72' y='461.28' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='29.36px' lengthAdjust='spacingAndGlyphs'>Index</text></g>
<g clip-path='url(#cpMHw0ODB8NDgwfDA=)'><text transform='translate(12.96,244.48) rotate(-90)' style='font-size: 12.00px; font-family: Liberation Sans;' textLength='23.36px' lengthAdjust='spacingAndGlyphs'>1:10</text></g>
</svg>

svglite documentation built on Sept. 12, 2017, 1:04 a.m.