0
$\begingroup$
L = 1; ϕ = 1 Pi/180; KL = 1; KT = 1;

plot1 = Plot[(4*(-θ+ϕ)*KT+L^2/Cos[θ]*(1/Cos[ϕ]-1/Cos[θ])*KL*Tan[θ])/(L*(1/Cos[θ])^2), 
             {θ, -ϕ, ϕ }]



plot2 = Plot[-1/(2*L)*Cos[θ]^2*1/    Tan[θ]*(4*KT + KL*L^2*(1/Cos[θ])^2 - 
             KL*L^2*(1/Cos[θ])^3*1/Cos[ϕ] + 2*KL*L^2*(1/Cos[θ])^2*Tan[θ]^2 - 
             KL*L^2*1/Cos[θ]*1/Cos[ϕ]*Tan[θ]^2), 
             {θ, -ϕ, ϕ},    PlotRange -> Automatic]



Show[plot1, plot2, PlotRange -> Automatic]

As shown I can plot functions seperately and then use Show to plot them in one graph. The reason I do not get a good picture is because of different plot ranges. How could I change this?

Thanks

$\endgroup$
0

1 Answer 1

2
$\begingroup$

From Mathematica Documentation when searching for two axis plot (and this Q&A):

TwoAxisPlot[{f_, g_}, {x_, x1_, x2_}] := 
  Module[{fgraph, ggraph, frange, grange, fticks, gticks}, 
  {fgraph, ggraph} = MapIndexed[
    Plot[#, {x, x1, x2}, Axes -> True, 
    PlotStyle -> ColorData[1][#2[[1]]]] &, {f, g}];
  {frange, grange} = 
    (PlotRange /. AbsoluteOptions[#, PlotRange])[[2]] & /@ {fgraph, ggraph};
  (* small change here to have more ticks *) 
  fticks = N@FindDivisions[frange, 10]; 
  gticks = Quiet@Transpose@{fticks,ToString[NumberForm[#, 2], StandardForm] & /@
    Rescale[fticks, frange, grange]}; 

  Show[fgraph, ggraph /. 
    Graphics[graph_, s___] :> 
      Graphics[GeometricTransformation[graph, RescalingTransform[{{0, 1}, grange}, {{0, 1}, frange}]], s], 
    Axes -> False, Frame -> True, 
    FrameStyle -> {ColorData[1] /@ {1, 2}, {Automatic, Automatic}}, 
    FrameTicks -> {{fticks, gticks}, {Automatic, Automatic}}]]

Applying this to your case:

L = 1; ϕ = 1 Pi/180; KL = 1; KT = 1;
fun[θ_] := (4*(-θ + ϕ)*KT + L^2/Cos[θ]*(1/Cos[ϕ] - 1/Cos[θ])*KL*Tan[θ])/(L*(1/Cos[θ])^2)
fun2[θ_] := -1/(2*L)*Cos[θ]^2*1/Tan[θ]*(4*KT + KL*L^2*(1/Cos[θ])^2 - 
  KL*L^2*(1/Cos[θ])^3*1/Cos[ϕ] + 2*KL*L^2*(1/Cos[θ])^2*Tan[θ]^2 - 
  KL*L^2*1/Cos[θ]*1/Cos[ϕ]*Tan[θ]^2)

TwoAxisPlot[{fun@θ, fun2@θ}, {θ, -ϕ, ϕ}]

enter image description here

$\endgroup$

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