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 am plotting several functions, some of which have fillings. After I combine all the functions together on a plot and export the plot to an EPS file, the fillings obstruct other lines. Exported PDF files are fine.

Minimal Working Example:

  Plot[.5, {x, -1, 2}, PlotStyle -> {Thick, Dashed}],
  Plot[Sinh[x], {x, -1, 2}, Filling -> Axis]]

(I know I can write the two functions into a single Plot command, but I have to use Show to combine several separate plots in the real problem.)

Link to the exported EPS file

I can avoid the obstruction by saving the graphic as a bitmap, but the overall quality seems to be degraded.

share|improve this question
up vote 8 down vote accepted

Reverse your Plot calls in the Show function:

Show[Plot[Sinh[x], {x, -1, 2}, Filling -> Axis],
     Plot[.5, {x, -1, 2}, PlotStyle -> {Thick, Dashed}]]

Filling using transparency, and .eps doesn't support transparency, so upon export it sets the opacity equal to one. Since you are showing the line first, the filled plot is drawn on top of it and obscures the line upon export.

Edit: If you want to maintain the PlotRange set by the line plot, extract the PlotRange option by first plotting it by itself:

pl = Plot[.5, {x, -1, 2}, PlotStyle -> {Thick, Dashed}]
range = Options[pl, PlotRange];

And then use that to set the PlotRange option of the first plot:

Show[Plot[Sinh[x], {x, -1, 2}, Filling -> Axis, Evaluate@range], pl]

enter image description here

share|improve this answer
Thanks. That's helpful. Now I know why there couldn't be two fillings overlapping in EPS output. However in my work the combined picture needs the frame from the line plotting. And in the Show command it is always the first picture that makes the frame. I am trying to apply the same frame to the filling but without success. – TigTig Mar 5 '13 at 4:52
I edited my answer to address your comment. – Guillochon Mar 5 '13 at 5:26

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.