- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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.
- 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.
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()
- 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 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