- Trending Categories
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 independently set horizontal and vertical, major and minor gridlines of a plot?
To set horizontal and vertical, major and minor grid lines of a plot, we can use grid() method.
Steps
- Set the figure size and adjust the padding between and around the subplots.
- Create a figure and a set of subplots.
- Make horizontal grid lines for major ticks.
- Locate minor locator on the axes.
- Use grid() method to make minor grid lines.
- To display the figure, use show() method.
Example
import matplotlib.pyplot as plt from matplotlib.ticker import MultipleLocator plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() ax.yaxis.grid(which="major", color='r', linestyle='-', linewidth=2) ml = MultipleLocator(0.10) ax.xaxis.set_minor_locator(ml) ax.xaxis.grid(which="minor", color='k', linestyle='-.', linewidth=0.7) plt.show()
Output
- Related Articles
- Add minor gridlines to Matplotlib plot using Seaborn
- Pandas timeseries plot setting X-axis major and minor ticks and labels
- Getting vertical gridlines to appear in line plot in matplotlib
- How to set the horizontal and vertical radius of an Ellipse using FabricJS?
- How to add minor gridlines in an Excel chart?
- How to compose a raw device number from the major and minor device numbers?
- How to Create Horizontal and Vertical Tabs using JavaScript?
- How to create a plot in R with gridlines using plot function?
- CSS Central, Horizontal and Vertical Alignment
- Difference between Horizontal and Vertical Relationships
- How to create a bar graph using ggplot2 without horizontal gridlines and Y-axes labels in R?
- How to scale a Text object equally to horizontal and vertical direction using FabricJS?
- Vertical and Horizontal Scrollbars on Tkinter Widget
- Difference between vertical integration and horizontal integration
- Difference between Horizontal Equity and Vertical Equity

Advertisements