Skip to contents

wrdPlot() captures plotting code for toWrd(), which renders it to a picture of the requested size and inserts it into Word. Besides such captured code, toWrd() accepts recorded base graphics (recordPlot(), e.g. the current plot in RStudio), ggplot2 and lattice objects.

Usage

wrdPlot(expr, env = parent.frame())

Arguments

expr

plotting code, e.g. {hist(x); abline(v = 0)}. Not evaluated by wrdPlot(). A visible ggplot or trellis result is printed.

env

environment in which expr is evaluated.

Value

wrdPlot(): an object of class "WrdPlot".

Details

The plot is drawn anew on a file device of the requested size, so fonts and symbols keep their size in the document, independently of the size of the screen device. Like all output of toWrd() a plot can be placed in an updatable bookmark (bookmark = "name"); a generated name starts with "bmp".

See also

Examples

if (FALSE) { # \dontrun{
toWrd(wrdPlot(hist(rnorm(100))), width = 12)

plot(cars); abline(lm(dist ~ speed, cars))
toWrd(recordPlot(), bookmark = "bmpCars")      # the current plot

# vector graphics, picture left aligned
toWrd(wrdPlot(boxplot(count ~ spray, InsectSprays)), type = "emf",
      align = "l")
} # }