# How can I save a density plot as a EPS file, but not a large file?

How can I have a small size (.EPS) DensityPlot? In fact, I want to bring a lot of density plots in my paper and the teX file will be very heavy. What can I do?

• DensityPlots are color gradient images. Exporting them into pure vector graphics typically either blows their size up or they look shabby. Maybe exporting a ContourPlot as vector graphic is more feasbile for you... – Henrik Schumacher May 5 '18 at 18:44
• You must be one of the few people who are still using .eps file format for latex. Everyone has moved to PDF for images with latex long time ago. – Nasser May 5 '18 at 19:10
• @ Nasser : Actually, the journal forced the authors – Perfect Fluid May 5 '18 at 19:14
• @ Henrik Schumacher: Would you kindly please guid me more clearly. Tanx – Perfect Fluid May 5 '18 at 19:15
• @Ak68 (I stumbled upon this just by chance because I was not pinged. There must be no whitespace between the @ and the user name.) If you already have a working Mathematica -> pdf pipeline for export, the simplest way to produce eps files would be to use external tools such as pdf2eps in the command line. Inscape is also an option. Actually, the last time I tried (several years ago, though), I found that the Mathematica eps export was rather buggy. – Henrik Schumacher May 5 '18 at 20:34

You probably need to replace the density plot with a Raster. The following makes a 28KB PDF file (sorry, my EPS exporter does not seem to work -- I always use PDF in TeX these days), which approximates DensityPlot[Sin[x] Sin[y], {x, -4, 4}, {y, -3, 3}]. The DensityPlot[..] took 1.8MB.

Legended[
Graphics[
Raster[
Rescale@
Table[Sin[x] Sin[y], {y, Subdivide[-3., 3., 100]}, {x, Subdivide[-4., 4., 100]}],
],
FrameTicks -> {
{ChartingScaledTicks[{1/2 (100 + 33 #) &, -3 + 6 (# - 1/2)/99 &}],
ChartingScaledFrameTicks[{1/2 (100 + 33 #) &, -3 + 6 (# - 1/2)/99 &}]},
{ChartingScaledTicks[{1/8 (400 + 99 #) &, -4 + 8 (# - 1/2)/99 &}],
ChartingScaledFrameTicks[{1/8 (400 + 99 #) &, -4 + 8 (# - 1/2)/99 &}]}},
Frame -> True],

You can adjust the raster size and ImageSize to suit. If they all have the same dimensions and ranges, it might not be a headache. Or one could try to write a general purpose function to do the above. The functions in the ticks just map forward and back between the raster domain {1, 100} and the function domains, {-4., 4.} for x and {-3., 3.} for y.