matplotlib.pyplot.twinx

matplotlib.pyplot.twinx(ax=None)[source]

Make and return a second Axes that shares the x-axis. The new Axes will overlay ax (or the current Axes if ax is None), and its ticks will be on the right.

Examples

Plots with different scales

Examples using matplotlib.pyplot.twinx

Plots with different scales

Plots with different scales

Percentiles as horizontal bar chart

Percentiles as horizontal bar chart

© 2012–2023 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.twinx.html