Learn R Programming

Kmisc (version 0.5.0)

hSvg: Print SVG to File and Return HTML

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

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

Run this code
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 )
)

Run the code above in your browser using DataLab