Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I usually export graphics from Mathematica as PDFs which I tweak with Adobe Illustrator. When most plots are exported from Mathematica as PDFs they contain a large number of mostly useless clipping masks.


Plot[Sin[x], {x, -Pi, Pi}]

Mathematica graphic

All the clipping masks can be removed from this PDF with no effect on the look of the plot.

Is there a way to have the PDF exported without clipping masks or somehow remove them automatically after export, ideally with Mathematica?

Note: in some cases (see below) the clipping masks are needed but I don't need a smart solution, if I can get it of all the clipping masks, useless and useful thats fine.

Plot[Sin[x], {x, -2 Pi, 2 Pi}, PlotRange -> {{-Pi, Pi}, All}]
share|improve this question
Do you see the masks when opening the doc with other programs? – Dr. belisarius Jul 23 '12 at 19:16
@belisarius It's a feature of the PDFs, it should be visible in any decent vector editor that supports PDF. – Szabolcs Jul 23 '12 at 19:23
I would try re-processing the PDFs with various programs (xpdf? ghostscript?) and see if that reomoves the masks. I know the problem well, but I haven't tried to come up with an automated solution yet. – Szabolcs Jul 23 '12 at 19:24
@Szabolcs define "decent" :) – Dr. belisarius Jul 23 '12 at 19:38
Once upon a time I fixed some EPS bounding box issues by stringbased postprocessing of Mathematica output. Are the masks easily identified in a PDF? – Yves Klett Jul 23 '12 at 19:56
up vote 3 down vote accepted

If you are willing to export to eps first and then convert to pdf, try if this works for you. I think it does for me. It is a pretty dirty hack though, so there might be side effects I haven't noticed.

p=Plot[Sin[x], {x, -Pi, Pi}];
Export["plot.eps",StringReplace[ExportString[p,"EPS"],"clip np"->""],"Text"]

Also, it might not work for all plots.


Actually there is a pretty obvious side effect in form of a colored border around the actual curve. I think with a little more tinkering one might be able to get rid of that too.

share|improve this answer

Your Answer


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.