# Plotting two functions into one plot with two y-axes. Is there a built option for this in newer versions of Mathematica?

I am looking into possibilities to plot two functions into one Plot, but with separate y-axes. I came across several variants of how to do this when searching for it, such as in this thread here. Other approaches make use of Overlay.

However none of these methods is really simple and user friendly, and since all questions I came across have been asked 5+ years ago, I thought I ask if Mathematica built in this option in the meantime directly into Plot, ParametricPlot, ListPlot, etc.?

Thanks!

• There is a resource function called CombinePlots. Jul 20, 2020 at 21:17
• Jul 20, 2020 at 21:21
• Thanks for the link to the resource function @Tim Laska ! This would qualify as answer. If you want to give it, I can mark it as such. Thanks also for the link @Bob Hanlon ! This was one of the solutions I came across when searching for it. The CombinePlots resource function seems to be better in the sense that it seems to be more versatile in the sense of parsing options and w. r. t. the question which kind of plots can be used. Jul 21, 2020 at 11:15

There is a resource function called CombinePlots that is supposed to operate like Show and offers a fair amount of flexibility.

An example usage from the documentation is shown in the following:

cp = ResourceFunction["CombinePlots"];
cp[
Plot[x^2, {x, 0, 10}, Frame -> True],
Plot[
100 x^4, {x, 0, 10},
ScalingFunctions -> "Log",
Frame -> True, FrameStyle -> Red, PlotStyle -> Red
],
"AxesSides" -> "TwoY"
]


One can easily setup a secondary x and y axes as shown:

cp[
Plot[Cos[x], {x, 0, 10}, Frame -> True],
Plot[1 + 10 Sin[x]^2, {x, 0, 30}, ScalingFunctions -> "Log",
Frame -> True, FrameStyle -> Red, PlotStyle -> Red],
"AxesSides" -> "TwoXY"
]