
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to move the Y-axis ticks from the left side of the plot to the right side in matplotlib?
To shift the Y-axis ticks from left to right, we can perform the following steps −
Create a figure using the figure() method.
Using the above figure method, create the axis of the plot, using add_subplot(xyz), where x is row, y is column, and z is index.
To shift the Y-axis ticks from left to right, use ax.yaxis.tick_right() where ax is axis created using add_subplot(xyz) method.
Now plot the line using plot() method, with given x and y points, where x and y points can be created using np.array() method.
Set up x and y labels, e.g., X-axis and Y-axis , using xlabel and ylabel methods.
Use plt.show() to show the figure.
Example
from matplotlib import pyplot as plt import numpy as np f = plt.figure() ax = f.add_subplot(111) ax.yaxis.tick_right() xpoints = np.array([0, 5]) ypoints = np.array([0, 5]) plt.plot(xpoints, ypoints) plt.ylabel("Y-axis ") plt.xlabel("X-axis ") plt.show()
Output
- Related Questions & Answers
- How to plot the X-axis labels on the upper-side of the plot in R?
- How to plot two Seaborn lmplots side-by-side (Matplotlib)?
- How to plot two histograms side by side using Matplotlib?
- Python Pandas - Check whether the interval is closed on the left-side, right-side, both or neither
- Python Pandas - Check whether the IntervalIndex intervals are closed on the left-side, right-side, both or neither
- Python Pandas - Check whether the intervals in IntervalArray are closed on the left-side, right-side, both or neither
- How to align checkbutton in ttk to the left side?
- How to turn on minor ticks only on the y-axis Matplotlib?
- How to change the color of the axis, ticks and labels for a plot in matplotlib?
- How to plot bar graphs with same X coordinates side by side in Matplotlib?
- How to remove the label on the left side in matplotlib.pyplot pie charts?
- Show the origin axis (x,y) in Matplotlib plot
- How to move the horizontal slider right-to-left in Java?
- How to remove the first and last ticks label of each Y-axis subplot in Matplotlib?
- How to change the range of the X-axis and Y-axis in Matplotlib?
Advertisements