Description Usage Arguments Details Value Author(s) Examples
printAndSave is a wrapper around ggsave. It prints a ggplot2 object to the console/knitr report and saves as a graphic file. It defaults to larger fonts for the graphic file (more suitable for PPT). Graphic filetype is taken from the given filename and can be one of (png, bmp, tiff, jpg, pdf, svg).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
plotObject |
A ggplot2 plotobject |
filename |
A path/filename for the graphic |
width |
Graphic width in inches (default = 7) |
height |
Graphic height in inches (default = 5) |
units |
Units for height and width ("in"|"cm"|"mm") (Default = "in") |
res |
Resolution in ppi (default=300) |
scale |
Multiplicative scaling factor (Default = 1) |
printFontSize |
Base font size for the graphic on the console/knitr (default=12) |
saveFontSize |
Base font size for the graphic file (default=24) |
scaleLegend |
Scale the legend smaller if font > 14 (Default = TRUE) |
printPlot |
Print to console if TRUE (Default=TRUE) |
savePlot |
Print to file if TRUE (Default = TRUE) |
I found I didn't like the default Legend sizes. I inserted code to increase the size of the print/knitr legend and decrease the size of the legend in the saved graphic file. This works well for images of about 5-7 inches but may not scale well to other image sizes. Set scaleLegend to FALSE to get the default behavior back or use legend.key.size in a theme to tweak to your own specifications.
The print object
John Thompson, jrt@thompsonclan.org
1 2 3 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.