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.


1 Answer 1


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

  • $\begingroup$ 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. $\endgroup$
    – TigTig
    Commented Mar 5, 2013 at 4:52
  • $\begingroup$ I edited my answer to address your comment. $\endgroup$
    – Guillochon
    Commented Mar 5, 2013 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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