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?
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.
UPDATE:
I just tried this option with ggplot2 2.2.1. If you save using the file ending
".tiff"
, and specifycompression = "lzw"
, (exactly as written by @SoilSciGuy), ggsave will now compress your image appropriately. Mine went from 2.98 MB to 37.6 KB.I would suggest to use tiff directly, like