Message Boards Message Boards

0
|
6131 Views
|
3 Replies
|
4 Total Likes
View groups...
Share
Share this post:

[?] Export ListContourPlot graphics partly rasterized?

Posted 6 years ago

It is always painful to export nice vector plots in raster format in order to get acceptable size of file. Thin lines, arrows etc. never look very fine (except may be 3000 dpi). For example this

Export["g.pdf",ListContourPlot[Table[RandomReal[],{30},{30}],
InterpolationOrder->2,PlotLegends->Automatic,FrameLabel->{"x","y"}]]

will give about 3Mb file but with option ContourShading?False it will be only 300Kb. Is it possible to replace vector objects for shades by raster? I want to keep vector form for all lines (contours, frame, labels, legend) in output PDF file.

POSTED BY: Rodion Stepanov
3 Replies
Posted 6 years ago

Does adding "AllowRasterization"-> False to the Export Command help?

( as per the discussions at: https://mathematica.stackexchange.com/questions/164718/export-to-pdf-densityplot-allowrasterization-false )

POSTED BY: Mitch Price

Sorry, I think I misunderstood at first reading. You may try to combine vector with raster using Inset:

cnpl = ListContourPlot[RandomReal[{-1, 1}, {30, 30}], 
   InterpolationOrder -> 2];
plgs = DeleteCases[cnpl, _Line, All];
new = ListContourPlot[RandomReal[{-1, 1}, {30, 30}], 
  InterpolationOrder -> 2, ContourShading -> False, 
  Prolog -> Inset[Rasterize[plgs]]]

The code needs some adjustments, but I don't have time now.

POSTED BY: Gianluca Gorni

This gives a 3.2MB vector plot on my system:

Export["~/Desktop/contorus.pdf", 
 ListContourPlot[RandomReal[{-1, 1}, {30, 30}], 
  InterpolationOrder -> 2], ImageResolution -> Infinity]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract