Matplotlib and seaborn 3 · Layout and styling

Two y-axes

Plot two series with different scales on the same chart.

fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(x, x ** 2, color="tab:blue")
ax2.plot(x, np.sqrt(x), color="tab:red")

Official Matplotlib and seaborn 3 documentation

More layout and styling commands

All layout and styling commands · Matplotlib and seaborn 3 cheatsheet

Was this page helpful?