10

Basically the same question as here, but now with regions which have opacity.

RegionPlot[x^2 + y^2 < 1, {x, -1, 1}, {y, -1, 1}, 
  PlotStyle -> Opacity[0.5, Black]];
Export["tmp/region.pdf", %]

How do I remove the black lines when exporting to pdf?

Maikel
  • 185
  • 1
  • 6
  • 1
    Does this solve your problem? --> http://mathematica.stackexchange.com/questions/644/how-can-all-those-tiny-polygons-generated-by-regionplot-be-joined-into-a-single – Szabolcs Jan 28 '13 at 20:28

3 Answers3

16

To get nice looking PDF export in this case is not easy. Export is really doing something wrong here. The best option I think would be to do the following:

regionplot = 
  RegionPlot[x^2 + y^2 < 1, {x, -1, 1}, {y, -1, 1}, 
   PlotStyle -> Opacity[0.5, Black]];

Export["region.pdf", 
 Show[regionplot, 
  Prolog -> {Opacity[0], Texture[{{{0, 0, 0, 0}}}], 
    VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}}, 
    Polygon[{{0, 0}, {.1, 0}, {.1, .1}}]}]
 ]

Here, I've tricked Mathematica into rasterizing the opaque parts of the plot by using Show to combine the RegionPlot with a single invisible textured polygon that triggers the rasterization upon Export. To insert this trick, I used a Prolog option, but instead you could also use Epilog. If you do this often, it would be convenient to define something like

rasterTrick[plot_] := 
 Show[plot, 
  Prolog -> {Opacity[0], Texture[{{{0, 0, 0, 0}}}], 
    VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}}, 
    Polygon[{{0, 0}, {.1, 0}, {.1, .1}}]}]

Export["region.pdf", regionplot // rasterTrick]

export

The above is the exported PDF.

This is borrowed from my earlier answer here, except that SetOptions in this case doesn't work properly as a way to make this trick stick with every RegionPlot.

Jens
  • 97,245
  • 7
  • 213
  • 499
3

The Adobe PDF generators that are built into various products appear to often be inferior to the results obtained "Printing" with Adobe Acrobat Professional. Using that method, instead of Export, I obtain:

enter image description here

David Park
  • 2,613
  • 18
  • 14
1

If you print directly to PDF (on Mac, you select image, Print Graphic..., then Save as PDF...), you get good results:

print

So it looks like you can work round the bug in Export.

(This is probably the equivalent of another answer, but doesn't involve giving any money to Adobe...)

cormullion
  • 24,243
  • 4
  • 64
  • 133
  • My HP Windows came with PDFComplete accessed from Print. But this was only a trial license that has expired. Using File, SaveSelection As.. gives the bad version. – David Park Jan 28 '13 at 20:54