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.

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:

Show[
  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
add comment

1 Answer

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
add comment

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.