This resource function is obsolete. Use the MultiaxisArrangement built-in symbol instead.

Function Repository Resource:

MultipleAxesPlot

Source Notebook

Display different vertical axes for two plotted expressions

Contributed by: Jon McLoone

ResourceFunction["MultipleAxesPlot"][{expr1,expr2},{x,xmin,xmax}]

generates a plot of expr1 and expr2 with two y-axes.

Details and Options

ResourceFunction["MultipleAxesPlot"] supports all of the options of Plot except Axes, ScalingFunctions, Frame, Ticks, TicksStyle and FrameTicks.

Examples

Basic Examples (1) 

Plot two functions with different scales:

In[1]:=
ResourceFunction["MultipleAxesPlot"][{Sin[x], 4 Cos[x]}, {x, 0, 6}]
Out[1]=

Options (3) 

To make it clearer which axes refers to which line, you can use "SecondaryAxesColor":

In[2]:=
ResourceFunction["MultipleAxesPlot"][{Sin[x], Exp[x]}, {x, 0, 6}, PlotStyle -> {Black, Blue}, "SecondaryAxesColor" -> Blue]
Out[2]=

You can control the plot ranges of the two lines using PlotRange and "SecondaryPlotRange":

In[3]:=
ResourceFunction["MultipleAxesPlot"][{Sin[x], Exp[x]}, {x, 0, 6}, PlotRange -> {0, 1.1}, "SecondaryPlotRange" -> {100, 400}]
Out[3]=

PlotRangePadding applies to both functions but uses the coordinate system of the first function:

In[4]:=
ResourceFunction["MultipleAxesPlot"][{Sin[x], Exp[x]}, {x, 0, 6}, PlotStyle -> {Black, Blue}, PlotRangePadding -> {Automatic, 2}]
Out[4]=

Publisher

Jon McLoone

Version History

  • 5.0.0 – 19 December 2019
  • 4.0.0 – 25 September 2019
  • 3.0.0 – 13 March 2019
  • 2.0.0 – 04 March 2019
  • 1.0.0 – 20 February 2019

License Information