5,323
edits
(→Usage) |
|||
Line 25: | Line 25: | ||
===Line Graph=== | ===Line Graph=== | ||
===Pie Chart=== | ===Pie Chart=== | ||
===Saving Images=== | |||
[https://ggplot2.tidyverse.org/reference/ggsave.html ggsave documentation] | |||
<syntaxhighlight lang="R"> | |||
# Save as PDF | |||
ggsave("barchart_example.pdf", plot=plt, width=6, height=4, device="pdf") | |||
embedFonts(path.expand("barchart_example.pdf")) | |||
# Save as PNG | |||
ggsave("barchart_example.png", plot=plt, width=6, height=4, dpi=300) | |||
</syntaxhighlight> | |||
For embedding in a latex file, I recommend exporting as PDF. This allows exporting as a vector format with text. | |||
If you must export as a raster image (jpeg, png), set the dpi flag to get a high-resolution image. |