Is it possible to compress the file size of a figure using ggsave
? I have tried using the compression = "lzw"
argument, but the file size remains the same. (Using R studio .98.501 OS-X Yosemite)
My code:
ggsave("Figure1.tiff", width = 14, height = 8, dpi=600, compression = "lzw")
Is it possible to add a compression argument with ggsave?
UPDATE:
I just tried this option with ggplot2 2.2.1. If you save using the file ending ".tiff"
, and specify compression = "lzw"
, (exactly as written by @SoilSciGuy), ggsave will now compress your image appropriately. Mine went from 2.98 MB to 37.6 KB.
If you can, try saving the image as a PDF. They're really clean vector graphics (if you want to refine in something like Illustrator) and I typically see them in the 3-5 KB range.
I would suggest to use tiff directly, like
tiff("my_graph.tif", units="in", width=13.3, height=6.6, res=800, compression = "lzw")
my_graph <- ggplot(....)
dev.off()