hSvg: Print SVG to File and Return HTML

Description Usage Arguments Examples

View source: R/html_extras.R

Description

A convenience function that prints a plot to file, and then returns HTML to embed that image in the page. Used for SVG images.

Usage

1
2
hSvg(my_plot, file, width = 400, height = 300, dim = NULL, scale = 100,
  ...)

Arguments

my_plot

a plot object, or code that generates a plot

file

location to output file

width

width (in pixels) of the plot

height

height (in pixels) of the plot

scale

the scale used to scale the plot from inches to pixels, for display in a web browser

dim

passed to par( mfrow ); used if making multiple base-R plots

...

passed to svg

Examples

1
2
3
4
5
6
7
library(lattice)
## generate an xyplot, write it to file, and return HTML code that
## sources the generated image
dat <- data.frame( x = rnorm(100), y = rnorm(100) )
hSvg( file = "plot_output.svg",
  xyplot( y ~ x, dat )
)

Example output

<div align='center'>
<embed src="plot_output.svg" width=400 height=300 type="image/svg+xml" />
</div>

Kmisc documentation built on May 29, 2017, 1:43 p.m.

Related to hSvg in Kmisc...