1
$\begingroup$

I am using Overlay to plot two curves in one graph while one of the curves is on a second vertical axis. How can I shift one of the curves (the dashed one here) upward to be above all other curves?

gamma4 = .4; gamma3 = .284; gamma2 = .265; gamma1 = .484; z3 = 10000; 
z2 = 32000; z1 = 75000; zbar4 = 4800; zbar3 = 20050; zbar2 = 46200;
zbar1 = 138100; h4 = .301; h3 = .404; h2 = .25;
h1 = .045; p1 = 3.89; p2 = 4.92; p3 = 5.22;
p4 = 5.39; g1 = 0; g2 = 0.44; g3 = 0.88; g4 = 1.76;

Gain2 = 
  h2 (zbar2 - z2) + h1 (z1 - z2) + 
    (a (g1 p1 + (g2 p2/τ2) + g3 p3 + g4 p4) - 1) h2 zbar2 gamma2 (τ2/(1 - τ2));

d0 = Show[Plot[Evaluate @ Table[Gain2, {a, 0.05, 0.09, 0.01}], {τ2, 0, 1}]]

d2 = 
  Show[
    Plot[Evaluate @ Table[Gain2, {a , 100, 100, 100}], {τ2, 0, 1}, 
      Axes -> None, PlotStyle -> {Directive[Black, Dashed]}]]

d = Overlay[{d0, d2}]
$\endgroup$
6
  • $\begingroup$ Why not just add an appropriate constant to the functions you want to shift? $\endgroup$ Sep 2, 2017 at 4:28
  • $\begingroup$ Since it is on a second axis, adding constant didn't help. $\endgroup$
    – Hossein
    Sep 2, 2017 at 4:33
  • $\begingroup$ Why can't you plot both in one Plot[]? $\endgroup$ Sep 2, 2017 at 4:33
  • $\begingroup$ Because the second one (d2) is way larger that the first one (d0). $\endgroup$
    – Hossein
    Sep 2, 2017 at 4:35
  • $\begingroup$ Then, why not rescale the last one? Trying it out, a scale factor of 1.*^-4 looks reasonable. $\endgroup$ Sep 2, 2017 at 4:58

1 Answer 1

1
$\begingroup$

Overlay is not the appropriate tool for what you a trying to do. Since the vertical ranges of the two plots are so disparate, I recommend simply stacking the two plots with GraphicsColumn.

gamma4 = .4; gamma3 = .284; gamma2 = .265; gamma1 = .484; 
z3 = 10000; z2 = 32000; z1 = 75000; 
zbar4 = 4800; zbar3 = 20050; zbar2 = 46200; zbar1 = 138100; 
h4 = .301; h3 = .404; h2 = .25; h1 = .045; 
p1 = 3.89; p2 = 4.92; p3 = 5.22; p4 = 5.39; 
g1 = 0; g2 = 0.44; g3 = 0.88; g4 = 1.76

Gain2 = 
  h2 (zbar2 - z2) + h1 (z1 - z2) + 
    (a (g1 p1 + (g2 p2/τ2) + g3 p3 + g4 p4) - 1) h2 zbar2 gamma2 (τ2/(1 - τ2));

d0 = 
  Plot[Evaluate @ Table[Gain2, {a, 0.05, 0.09, 0.01}], {τ2, 0, 1},
    PlotRange -> {Automatic, {0, Automatic}}]];
d2 = 
  Plot[Gain2 /. a -> 100, {τ2, 0, 1},
    AxesOrigin -> {0, 6*^7},
    PlotRange -> {Automatic, {2*^5, Automatic}},
    PlotStyle -> Directive[Black, Dashed]]

GraphicsColumn[{d2, d0}]

plot

Notes

  • Show is not necessary.
  • I adjust PlotRange and AxesOrigin so as to convince the viewer to see the stacked graphs as being in a single viewport although they are not.
$\endgroup$

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.