I have a big amount of data from which I would like to create a scatter plot and include it in my LaTeX document. I use gnuplot to generate the scatter plot with the epslatex output format to be able to import the data to my LaTeX document easily.
My problem is that the EPS files are way too big (approximately 14MB per figure) which will result in a very big output document. Clearly the reason is that all of the data is included in the EPS file which is not needed.
However, I couldn't find a way to compress the EPS file. The only way is to reduce the number of sample points I have but for technical reasons I would prefer not to do that.
Can anyone suggest me a way to reduce the size of EPS plots?
I tried to use ImageMagick and reduce the resolution of the EPS files (like convert -units PixelsPerInch plot.eps -density 300 plot2.eps
) but it shrinks the dimensions which is not what I want.
Thanks in advance,
How to Compress EPS file. Upload EPS files to compress. Specify the parameters and press the "COMPRESS" button to compress EPS. Download the compressed EPS to view instantly or send a link to email.
My solution for this problem is the "every" command in gnuplot, i.e.
plot "datafile" u 1:2 every 10
Like this you can already reduce the size of the eps graphics by ~ a factor of 10. of course you need to find out yourself how much data you can omit without loosing too much information, i.e. the figure should still contain all the features you want to visualize.
If this is not wanted, I normally convert the eps to a raster image of appropriate size and convert it back to eps. Also here you have to play around with the resolution etc
The problem with .eps files is not necessarily resolution (they are vector graphics), but the amount of information gnuplot includes when creating the file. Gnuplot has a tendency to draw .eps files with lots of extra information, especially for 2D plots and plots with lots of points. For instance, for a grid of red squares joined at the edges to make a big red square, gnuplot would draw tons of little red squares instead of the big square. This issue is mentioned at the end of this blog post, where they say that plot ... with image
creates a much smaller output than splot
for making heat maps.
It sounds like you are not using splot
, though, so you could try making a .pdf instead of .eps, and if you need .eps convert it using pdf2ps
or another program. That might help...
Out of curiosity, how many points are you plotting? If you could give an idea of the amount of data you use, along with some example code you are using right now, we might be able to give better ideas.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With