You are reading an old version of the documentation (v2.2.0). For the latest version see https://matplotlib.org/stable/
Version 2.2.0
matplotlib
Fork me on GitHub

Related Topics

This Page

Set default y-axis tick labels on the rightΒΆ

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

../../_images/sphx_glr_tick_label_right_001.png
import matplotlib.pyplot as plt
import numpy as np

plt.rcParams['ytick.right'] = plt.rcParams['ytick.labelright'] = True
plt.rcParams['ytick.left'] = plt.rcParams['ytick.labelleft'] = False

x = 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