Fix Python – Python Matplotlib Y-Axis ticks on Right Side of Plot

Question

Asked By – Jason Strimpel

I have a simple line plot and need to move the y-axis ticks from the (default) left side of the plot to the right side. Any thoughts on how to do this?

Now we will see solution for issue: Python Matplotlib Y-Axis ticks on Right Side of Plot


Answer

Use ax.yaxis.tick_right()

for example:

from matplotlib import pyplot as plt

f = plt.figure()
ax = f.add_subplot(111)
ax.yaxis.tick_right()
plt.plot([2,3,4,5])
plt.show()

enter image description here

This question is answered By – joaquin

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0