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$
  • 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$ – Okkes Dulgerci Aug 13 '18 at 13:43
  • $\begingroup$ Thanks, the result is the desired one, but I should use the parametric method. :( $\endgroup$ – TeM Aug 13 '18 at 14:31
  • $\begingroup$ You can try Will Robertson's FixPolygons package for joining the polygons. $\endgroup$ – Alexey Popkov Aug 13 '18 at 14:40
  • $\begingroup$ Does this help? Avoiding white lines inside filled area in RegionPlot exported as PDF or PS $\endgroup$ – Jens Aug 13 '18 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$ – Andreas Rejbrand Aug 13 '18 at 16:46
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$
  • $\begingroup$ Perfect! Thanks! $\endgroup$ – TeM Aug 13 '18 at 17:34
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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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