plot_2nd_yaxis

mdtools.plot.plot_2nd_yaxis(ax, x, y, ymin=None, ymax=None, ylabel='$y2$', legend_loc='best', **kwargs)[source]

Plot data to a second y-axis.

Create a twin matplotlib.axes.Axes of an existing matplotlib.axes.Axes sharing the same x-axis using matplotlib.axes.Axes.twinx() and plot data to the twin Axes using matplotlib.axes.Axes.plot().

Parameters:
  • ax (matplotlib.axes.Axes) – The matplotlib.axes.Axes from which to create a twin that shares the same x-axis. Data are plotted to the created twin axes.

  • x (array_like) – One dimensional array containing the x data.

  • y (array_like) – Array of the same shape as x containing the y data.

  • ymin (scalar, optional) – Left limit for plotting on the secondary y-axis. The left limit may be greater than the right limit, in which case the tick values will show up in decreasing order. Default is None, which means set the limit automatically.

  • ymax (scalar, optional) – Right limit for plotting on the secondary y-axis.

  • ylabel (str, optional) – Label for the secondary y-axis.

  • legend_loc (int or str, optional) – Position of the legend. See matplotlib.pyplot.legend() for possible arguments.

  • kwargs (dict, optional) – Keyword arguments to pass to matplotlib.axes.Axes.plot(). See there for possible keyword arguments.

Returns: