Alex Rivera | Logout

Reduce PDF file size of plots by filtering hidden objects

Asked 2013-05-21T08:31:28.300
9

While producing scatter plots of many points in R (using ggplot() for example), there might be many points that are behind the others and not visible at all. For instance see the plot below:

enter image description here

This is a scatter plot of several hundreds of thousands points, but most of them are behind the other points. The problem is when casting the output to a vector file (a PDF file for example), the invisible points make the file size so big, and increase memory and cpu usage while viewing the file.

A simple solution is to cast the output to a bitmap picture (TIFF or PNG for example), but they lose the vector quality and can be even larger in size. I tried some online PDF compressors, but the result was the same size as my original file.

Is there any good solution? For example some way to filter the points that are not visible, possibly during generating plot or after it by editing PDF file?

Edit
Report

1 Answer

4

Simply saving the plot as a high-res png file will very drastically cut the size, while keeping the quality more than good enough. At least I've never had journals complain about any of the png's I sent them, just keep sure to use > 600 dpi.

answered 2013-05-21T12:04:22.537

Your Answer