Add a Stem plot to a PowerPoint or Word document as a native chart
Source:R/officer.R
stem_add_chart.RdConverts plot with stem_as_mschart() and adds it to an existing officer
document. For a PowerPoint document the chart is placed on the current
slide, so add a slide with officer::add_slide() first.
Usage
stem_add_chart(
x,
plot,
width = NULL,
height = NULL,
left = NULL,
top = NULL,
units = "cm",
location = NULL,
...
)Arguments
- x
An
officer::read_pptx()orofficer::read_docx()document.- plot
A ggplot2 object created by a Stem plotting function, or an
ms_barchartalready produced bystem_as_mschart().- width, height
Size of the chart, in
units. In Word both default to a readable 15 x 10 cm. In PowerPoint both default toNULL, which uses the body placeholder of the slide layout; give them to size the chart by hand.- left, top
PowerPoint only: position of the chart's top-left corner, in
units. Only used whenwidthandheightare given; both default to0.- units
Unit of
width,height,leftandtop:"cm"(default),"mm"or"in".- location
PowerPoint only: an
officer::ph_location()giving where to place the chart. Takes precedence overwidth/height/left/top.- ...
Passed to
stem_as_mschart().
Examples
if (FALSE) { # \dontrun{
doc <- officer::read_pptx()
doc <- officer::add_slide(doc, "Title and Content", "Office Theme")
doc <- stem_add_chart(doc, stem_barplot(trust, government))
print(doc, target = "chart.pptx")
} # }