9

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?

carlosdc
  • 12,022
  • 4
  • 45
  • 62
  • 1
    You may have better luck with a .png or .svg file. – Gregor Thomas Mar 05 '12 at 19:17
  • When people report this kind of problem my first guess is always that you have specified a pdf that is 32 inches by 32 inches. That's big! Check the default units in `ggsave` or `pdf` and adjust accordingly. – joran Mar 05 '12 at 19:18
  • @joran: it was ggsave. fixed it. can you please put your comment as an answer so I can accept it? – carlosdc Mar 05 '12 at 19:36
  • 1
    also consider `geom_raster` or `annotation_raster` if your tiles have regular sizes. – baptiste Mar 05 '12 at 19:53

1 Answers1

7

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.

joran
  • 169,992
  • 32
  • 429
  • 468