0
$\begingroup$

I have the following plot code

f[x_] := x /. {NumberForm[y_, {w_, z_}] :> ScientificForm[y, 2]}
f21fps = Show[SmoothDensityHistogram[data21fps,
   PlotRange -> {{0, 200}, {0, 200}}, 
   ColorFunction -> "SunsetColors",
   FrameLabel -> {Text[Style["t2-t1", FontSize -> 14, Italic], 
      FormatType -> StandardForm], 
     Text[Style["t1", FontSize -> 14, Italic], 
      FormatType -> StandardForm]},
   PlotLabel -> "FPS", LabelStyle -> {FontFamily -> "Times", 14},
   PlotLegends -> 
    BarLegend[Automatic, LegendFunction -> f, 
     LegendMarkerSize -> 368]
   , Mesh -> 0
   ], Plot[x, {x, 0, 200}], ImageSize -> 400, PlotRangePadding -> 0]

enter image description here

The problem here is that the image is too large (data21fps has more than 10^5 data points) when exported to PDF format (other formats reduce the size e.g. EPS but in a PDF document, after distiller action, look worse). Besides, if I insert 12 images of this type into a document, the PDF renders poorly.

Digging in the posts database, I have found a possible solution in the following link rasterized-image-together-with-vector-graphics-axes which Rasterize a ListDensityPlot, similar to my image but leaves the axes-object in vector format. Axes in vector format result useful to maintain the quality of visualization. However, I am not able to use the proposed function rasterizeBackground[] correctly with my density plot. This function will reduce the size of my file and will solve the issue exposed in my precedent post remove-artifact-of-pdf-images.

I would like to ask how can I use this rasterize method to downsize the plot, or if there is another one to get my images reduced.

Thank you very much for your help.

$\endgroup$
  • $\begingroup$ Did you already check whether you can get acceptable results by playing with PlotPoints and MaxRecursion? $\endgroup$ – Lukas Lang Aug 11 '17 at 9:01
  • $\begingroup$ If you are building PDF from TeX why not to use .PNG images? tex.stackexchange.com/questions/157299 $\endgroup$ – Vitaliy Kaurov Aug 11 '17 at 9:03
  • $\begingroup$ @VitaliyKaurov Thank you for answering. I have tested PNG in the TeX file. However, the image has poor quality when converted the document to PDF format. The main drawback is the axis and the numbers. $\endgroup$ – user1993416 Aug 11 '17 at 9:25
  • $\begingroup$ @Mathe172 Is correct. Using PlotPoints->16 and MaxRecursion->2, reduces the size of the plot from 3.5MB to 500KB. However, I still am having the problem 'artifact' mentioned in the note of this post and it was not only an issue of file size but the vectorization of the image. I would like to test the rasterizedBackground[]method. Please, could you help me to use it without the errors obtained when applying it to my density image. Thank you very much. $\endgroup$ – user1993416 Aug 11 '17 at 10:47

Your Answer

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

Browse other questions tagged or ask your own question.