I encountered a similar problem where a scatter plot of more than 10^6 points resulted in PDF files of >100 MB. The points were drawn with a very low opacity (1%) so only many layered points would be visible at all, resulting in something more of a smooth density distribution rather than a scatter plot. Thus, I was very reluctant to follow Raphael Roth's advise and thin out the data.
Instead, I found it useful to create a separate Gnuplot script to plot the data using the pngcairo
terminal to PNG bitmap images of sufficient resolution. This plot has no axes, not tics, no border and no margins -- just the data drawn in the appropriate coordinates:
set terminal pngcairo transparent size 400,400
set output 'foo.png'
set margins 0,0,0,0
set border 0
unset xtics
unset ytics
# set xrange, yrange appropriately
plot ... with points notitle
Then, in the actual plot (for which I used the cairolatex
terminal), I plot this PNG image:
set terminal cairolatex pdf
# regular setup, using the same xrange and yrange
plot 'foo.png' binary filetype=png with rgbalpha axes x2y2
Note that I plot using the other (ticless) set of axes to ensure that the image is filling the graph area without any border, so the tics on the x1y1 axes match the actual position of the points the scatter plot.
The PNG ended up being only a few dozen kilobytes, the PDF was a couple of MB. I think the rgbalpha
plot style (similar to with image
) is not the most efficient but this was good enough for me.
Hope someone will find this useful.