- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 print the Y-axis label horizontally in a Matplotlib/Pylab chart?
Just by using plt.ylabel(rotation='horizontal'), we can align a label according to our requirement.
Steps
Plot the lines using [0, 5] and [0, 5] lists.
Set the y-label for Y-axis, using ylabel method by passing rotation='horizontal'.
Set the x-label for X-axis, using xlabel method.
To show the plot, use plt.show() method.
Example
from matplotlib import pyplot as plt plt.plot([0, 5], [0, 5]) plt.ylabel("Y-axis ", rotation='horizontal') plt.xlabel("X-axis ") plt.show()
Output
Advertisements