title: Two axis plot, one of the curves is incomplete
body: <p>I'm using TwoAxisPlot to combine two plots for functions from an NDSolve, but the result has one of the curves truncated and is hence incomplete. I don't understand all the jargon when defining the TwoAxisPlot function so I don't know the origin of the problem. Code is as follows: </p>
  
  <pre><code>a = 0.99*10^-9;
  b = 0.24*10^-3;
  d = 1.21*10^-3;
  T0 = 1*10^6;
  n0 = 0.9*10^9;
  ti = -20;
  tf = 500;
  kB = 1.38*10^-16;
  
  Qb = 0.33*10^-3;
  sig = 1;
  var = sig^2;
  Ag = 16.5;
  
  Qg = Ag* Exp[-(t - 10)^2/(2*var)];
  Qgt = Qg + Qb;
  
  sss = NDSolve[{T'[t] == -(n[t]^-1) T[t]^(7/2) (a) - 
    n[t] T[t]^(-1/2) (b) + Qgt/(2*kB*n[t]), 
  n'[t] == T[t]^(5/2) (a) - (n[t]^2) (T[t]^(-3/2)) (d), T[ti] == T0,
   n[ti] == n0}, {T, n}, {t, ti, tf}];
  </code></pre>
  
  <p>This gives me two interpolating functions which I can plot fully individually:</p>
  
  <pre><code>TP = Plot[T[t] /. sss, {t, ti, 300}, PlotRange -&gt; All];
  TPPa = Show[TP, Frame -&gt; True, 
  FrameLabel -&gt; {{"Temperature, K", ""}, {"Time, s", ""}}]
  
  NP = Plot[n[t] /. sss, {t, ti, 300}, PlotRange -&gt; All];
  NPPa = Show[NP, Frame -&gt; True, 
  FrameLabel -&gt; {{"Density, \!\(\*SuperscriptBox[\(cm\), \(-3\)]\)", 
   ""}, {"Time, s", ""}}]    
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JfeS7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JfeS7.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/vEy4X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vEy4X.png" alt="enter image description here"></a></p>
  
  <p>I then define the TwoAxisPlot function, unchanged, copied from this website: <a href="https://reference.wolfram.com/language/howto/GeneratePlotsWithTwoVerticalScales.html" rel="nofollow noreferrer">Wolfram Documentation Center</a></p>
  
  <pre><code>TwoAxisPlot[{f_, g_}, {x_, x1_, x2_}] := 
  Module[{fgraph, ggraph, frange, grange, fticks, 
  gticks}, {fgraph, ggraph} = 
  MapIndexed[
  Plot[#, {x, x1, x2}, Axes -&gt; True, 
    PlotStyle -&gt; ColorData[1][#2[[1]]]] &amp;, {f, g}]; {frange, 
  grange} = (PlotRange /. AbsoluteOptions[#, PlotRange])[[
    2]] &amp; /@ {fgraph, ggraph}; fticks = N@FindDivisions[frange, 5];
  gticks = 
  Quiet@Transpose@{fticks, 
    ToString[NumberForm[#, 2], StandardForm] &amp; /@ 
     Rescale[fticks, frange, grange]};
  Show[fgraph, 
  ggraph /. 
  Graphics[graph_, s___] :&gt; 
   Graphics[
    GeometricTransformation[graph, 
     RescalingTransform[{{0, 1}, grange}, {{0, 1}, frange}]], s], 
  Axes -&gt; False, Frame -&gt; True, 
  FrameStyle -&gt; {ColorData[1] /@ {1, 2}, {Automatic, Automatic}}, 
  FrameTicks -&gt; {{fticks, gticks}, {Automatic, Automatic}}]]
  </code></pre>
  
  <p>and use it</p>
  
  <pre><code>TwoAxisPlot[{T[t] /. sss, n[t] /. sss}, {t, -20, 300}]
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/JfeS7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LlDGo.png" alt="enter image description here"></a></p>
  
  <p>but the plot is now truncated and doesn't show the full curve. How can I fix this?</p>