- 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
Getting vertical gridlines to appear in line plot in matplotlib
Using plt.grid(axis="x") method, we can plot vertical gridlines.
Steps
Make a list of numbers.
Set the X-axis label using plt.xlabel() method.
Set the Y-axis label using plt.ylabel() method.
Toggle the gridlines, and optionally set the properties of the lines, using plt.grid() method.
To show the figure, use the plt.show() method, where the argument axis can be “x”, “y” or “both”.
Example
from matplotlib import pyplot as plt plt.plot([0, 5], [0, 5]) plt.ylabel("Y-axis ") plt.xlabel("X-axis ") plt.grid(axis="x") plt.show()
Output
Advertisements