Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot2/R output pdf too large

I'm generating a 32x32 (tiles, each tile less than a quarter inch x a quater inch size) heatmap in ggplot2 in my MacBook Pro, this is relatively simple stuff. However, the pdf output for this is huge (something like 7MB) and when I load it in pdflatex, loading and changing pages in the document becomes very slow. What are my options? Is there a better way to save a PDF in R that plays nicely with ggplot2 and pdflatex?

like image 527
carlosdc Avatar asked Mar 05 '12 19:03

carlosdc


1 Answers

A common source of PDFs that are way too big is specifying dimensions when saving, thinking you're working in pixels, when in fact the default is in inches.

Try changing either the units (in ggsave) or the sizes in pdf.

like image 99
joran Avatar answered Oct 24 '22 07:10

joran