5
$\begingroup$

Writing:

plot = ParametricPlot[{x, Min[1, 2] t}, {x, 0, 2}, {t, 0, 1}, 
                       PlotRange -> {{0, 2}, {-1, 2}}]

I get:

enter image description here

but if I write:

Export["test.pdf", plot]

I get:

enter image description here

How can I get the same image in test.pdf?

$\endgroup$
5
  • 1
    $\begingroup$ How about this? plot = Plot[1, {x, 0, 2}, PlotRange -> {{0, 2}, {-1, 2}}, Frame -> True, Filling -> Axis, AspectRatio -> 1.5,PlotStyle -> Thin] $\endgroup$ Commented Aug 13, 2018 at 13:43
  • $\begingroup$ You can try Will Robertson's FixPolygons package for joining the polygons. $\endgroup$ Commented Aug 13, 2018 at 14:40
  • $\begingroup$ Does this help? Avoiding white lines inside filled area in RegionPlot exported as PDF or PS $\endgroup$
    – Jens
    Commented Aug 13, 2018 at 14:53
  • 1
    $\begingroup$ What's up with Min[1, 2] t? Surely that can be replaced by t alone? Or doesn't the problem reproduce then? $\endgroup$ Commented Aug 13, 2018 at 16:46
  • $\begingroup$ TeM, could you check if SetSystemOptions["VisualizationOptions" -> {"GraphicsComplexPolygonCombine" -> True}];plot = ParametricPlot[{x, Min[1, 2] t}, {x, 0, 2}, {t, 0, 1}, PlotRange -> {{0, 2}, {-1, 2}}];Export["test.pdf", plot] works in your version/OS? $\endgroup$
    – kglr
    Commented Aug 20, 2018 at 18:04

2 Answers 2

6
$\begingroup$

UPDATE: See more general solution in this answer.


You can solve this problem by joining the polygons using undocumented function Graphics`PolygonUtils`PolygonCombine:

plot = Normal@
   ParametricPlot[{x, Min[1, 2] t}, {x, 0, 2}, {t, 0, 1}, 
    PlotRange -> {{0, 2}, {-1, 2}}] /. 
  p : {__Polygon} :> Graphics`PolygonUtils`PolygonCombine[p];

Export["test.pdf", plot] // SystemOpen

Here is how the file is rendered by Adobe Acrobat:

screenshot

(checked with version 11.1.0).

$\endgroup$
0
2
$\begingroup$

Another workaround is to remove transparency from the polygons by specifying the PlotStyle explicitly:

plot = ParametricPlot[{x, Min[1, 2] t}, {x, 0, 2}, {t, 0, 1}, 
  PlotRange -> {{0, 2}, {-1, 2}}, Mesh -> None, 
  PlotStyle -> RGBColor[{0.812, 0.851, 0.914, 1}]]

output

Now the PDF

Export["test.pdf", %] // SystemOpen

is rendered as

screenshot

$\endgroup$

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.