1
$\begingroup$

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.

EDIT
Minimal working example:

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

data=Table[{x,y,RandomInteger[{1,7}]},{x,Range[100]},{y,Range[100]}];
op={ColorFunctionScaling->True,ColorFunction->"DarkBands",InterpolationOrder->0};
con=ListContourPlot[data,Evaluate@op];
den=ListDensityPlot[data,Evaluate@op];
Export["./con.pdf",con,"PDF"]; (* 74.2kB *)
Export["./den.pdf",den,"PDF"]; (* 22.6MB *)
$\endgroup$
  • $\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 Feb 11 '18 at 18:25
  • 1
    $\begingroup$ Rasterize the output. $\endgroup$ – David G. Stork Feb 11 '18 at 19:40
  • $\begingroup$ Have you seen Contours for ListContourPlot? $\endgroup$ – Edmund Feb 12 '18 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 Feb 12 '18 at 9:01
  • $\begingroup$ I've added a mwe. $\endgroup$ – Mor Roses Feb 12 '18 at 11:02
2
$\begingroup$

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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