I am trying to plot curves with the same x-range but different y-axis scales.
Here's my attempt:
X = Table[i, {i, 0, 2, 0.01}];
plot1 = ListLinePlot[Transpose[{X, X - 1}], PlotStyle -> Red , ImagePadding -> 25, AxesOrigin -> {0, 0}];
plot2 = ListLinePlot[Transpose[{X, Sqrt[X]}], Frame -> {False, False, False, True}, FrameTicks -> {{None, All}, {None, None}}, AxesOrigin -> {0, 0},
ImagePadding -> 25];
Overlay[{plot1, plot2}]
The output:
As seen in the figure above, the two origins are not aligned because the blue curve is not above the x-axis, i.e., not starting at (0,0), and the red curve is not starting at (0, -1) when the axes are combined.
I did consult the answers here. However, they don't seem to work in Mathematica 10. I've also tried to use the resource function MultipleAxesListPlot
, but I don't think it's supported in Mathematica 10. See the documentation of the resource function here.
Is there another method I can use to align the axes?
Your help will be much appreciated. Thank you.