Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question
1  
Does this solve your problem? --> mathematica.stackexchange.com/questions/644/… –  Szabolcs Jan 28 '13 at 20:28

3 Answers 3

up vote 10 down vote accepted

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.

share|improve this answer

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

share|improve this answer

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...)

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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