Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Matplotlib) expand_more
Matplotlib / Scales & Dates

Secondary axis

Learn Secondary axis in Matplotlib with a dedicated explanation, a topic-specific example, edge guidance, and a mastery check.

12 min read • Advanced
matplotlib-053.py
python
import matplotlib.pyplot as plt
import numpy as np
fig,ax=plt.subplots(); ax.plot([0,10,20],[32,50,68]); sec=ax.secondary_yaxis("right",functions=(lambda f:(f-32)*5/9,lambda c:c*9/5+32)); sec.set_ylabel("°C"); plt.show()
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content