I have been using ListContoutPlot to plot some data and then export it to a pdf file.

Seeing as the ListContourPlot has its own ideas regarding the placement of contours I've switched to ListDensityPlot, thus having the right contours (as I wanted).

But this resulted in a new issue for me, before the switch the outputted pdf file's size was ~5MB, now I'm getting file's size at around ~200MB. What options do I have if I want to maintain at least one high-quality output file (vector based image)?

I'm trying to keep an un-rasterized image file, but not at all cost.

Minimal working example:

On Mathematica, the resulting pdf's file size are 74.2kB for the ListContourPlot and 22.6MB for the ListDensityPlot.

Export["./con.pdf",con,"PDF"]; (* 74.2kB *)
Export["./den.pdf",den,"PDF"]; (* 22.6MB *)
  • $\begingroup$ Do you have a minimal working example (including data, real or not, and appropriate code to generate the .pdf or images in question) that demonstrates this issue for you that we can compare to? $\endgroup$
    – eyorble
    Commented Feb 11, 2018 at 18:25
  • 1
    $\begingroup$ Rasterize the output. $\endgroup$ Commented Feb 11, 2018 at 19:40
  • $\begingroup$ Have you seen Contours for ListContourPlot? $\endgroup$
    – Edmund
    Commented Feb 12, 2018 at 1:34
  • $\begingroup$ I'll try to get a mwe, not sure I can make something as detailed as what I'm currently plotting (current runtime is about 15min for the data and the plot). And I have tried Contours, ContourShading and pretty much any other option to specify contours... Only the density plot shows all of them. $\endgroup$
    – Mor Roses
    Commented Feb 12, 2018 at 9:01
  • $\begingroup$ I've added a mwe. $\endgroup$
    – Mor Roses
    Commented Feb 12, 2018 at 11:02

1 Answer 1


Try this:

Export["den.pdf", den, "PDF", ImageResolution -> 600, "AllowRasterization" -> True];

(* 82Kb *)

However, please, be advised that `AllowRasterization" needs avdavanced versions of PDF as documentation note.

I have no problem with Acrobat Reader DC in Windows 7 and MMA 11.2

  • 5
    $\begingroup$ Is there any way to maintain the vector nature of the plot while also minimizing file size? $\endgroup$
    – Mor Roses
    Commented Feb 12, 2018 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.