dml: Wrap plot instructions for DrawingML plotting in Powerpoint

View source: R/ph_with_vg.R

dmlR Documentation

Wrap plot instructions for DrawingML plotting in Powerpoint

Description

A simple wrapper to mark the plot instructions as Vector Graphics instructions. It produces an object of class 'dml' with a corresponding method ph_with.

The function enable usage of any R plot with argument code and with ggplot objects with argument ggobj.

Usage

dml(
  code,
  ggobj = NULL,
  bg = "white",
  fonts = list(),
  pointsize = 12,
  editable = TRUE,
  ...
)

Arguments

code

plotting instructions

ggobj

ggplot object to print. argument code will be ignored if this argument is supplied.

bg, fonts, pointsize, editable

Parameters passed to dml_pptx

...

unused arguments

background color

When dealing with a ggplot object argument bg will have no effect because ggplot theme is specifying background color, don't forget to define the colors you want in the theme:

theme(
  panel.background = element_rect(fill = "#EFEFEF"),
  plot.background = element_rect(fill = "wheat"))

See Also

ph_with.dml

Examples

anyplot <- dml(code = barplot(1:5, col = 2:6), bg = "wheat")

library(officer)
doc <- read_pptx()
doc <- add_slide(doc, "Title and Content", "Office Theme")
doc <- ph_with(doc, anyplot, location = ph_location_fullsize())
fileout <- tempfile(fileext = ".pptx")
# fileout <- "vg.pptx"
print(doc, target = fileout)

rvg documentation built on Sept. 11, 2024, 6:31 p.m.

Related to dml in rvg...