Note

Go to the endto download the full example code.

Set default y-axis tick labels on the right#

We can usercParams["ytick.labelright"] (default:False),rcParams["ytick.right"] (default:False),rcParams["ytick.labelleft"] (default:True),andrcParams["ytick.left"] (default:True) to control where on the axes ticks and their labelsappear. These properties can also be set in.matplotlib/matplotlibrc.

tick label right
importmatplotlib.pyplotaspltimportnumpyasnpplt.rcParams['ytick.right']=plt.rcParams['ytick.labelright']=Trueplt.rcParams['ytick.left']=plt.rcParams['ytick.labelleft']=Falsex=np.arange(10)fig,(ax0,ax1)=plt.subplots(2,1,sharex=True,figsize=(6,6))ax0.plot(x)ax0.yaxis.tick_left()# use default parameter in rcParams, not calling tick_right()ax1.plot(x)plt.show()

Gallery generated by Sphinx-Gallery