Recommended Free Tools
To show horizontal grid lines in Matplotlib, call ax.grid(axis="y") on your Axes object. To control whether those lines sit behind or in front of your bars, lines, and markers, call ax.set_axisbelow() with True, "line", or False. Both calls are part of the Matplotlib Axes API, and the sections below cover styling, tick groups, layering modes, and version differences.
Draw horizontal grid lines with Axes.grid
Horizontal grid lines are the gridlines that run along the y-axis, one at each y-tick. Matplotlib exposes them through the axis argument of Axes.grid. Passing axis="y" limits the grid to the y-axis, so vertical lines are not drawn.
As an Amazon Associate I earn from qualifying purchases.
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.bar(["Q1", "Q2", "Q3", "Q4"], [12, 18, 9, 15])
ax.grid(axis="y")
plt.show()
Three arguments control which gridlines appear and how they look:
axischooses the direction."y"gives horizontal lines,"x"gives vertical lines, and"both"draws both.whichchooses the tick group."major"uses major ticks,"minor"uses minor ticks, and"both"uses both groups. Minor gridlines only appear if the axis has minor ticks, which you add with a locator such asax.yaxis.set_minor_locator().- Line properties such as
color,linestyle, andlinewidthstyle the lines. They follow the same names as Line2D properties.
A light, dashed horizontal grid for a chart with both tick groups looks like this:
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
ax.grid(axis="y", which="both", color="0.85", linestyle="--", linewidth=0.7)
The value "0.85" is a grey shade on the 0 (black) to 1 (white) scale, which keeps the grid readable without competing with the data.
Put gridlines behind or in front of plotted data
Gridlines are drawn as part of the axis, so their layer is governed by the axis z-order. Axes.set_axisbelow sets that layer for the ticks and gridlines together. Its documentation describes it as setting “whether axis ticks and gridlines are above or below most artists.” It does not control individual gridlines separately.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
The method accepts three values. Each maps to a fixed z-order:
Free tools Windows power users keep installed
One-click scans. No signup required.
Value passed to set_axisbelow |
Gridlines and ticks drawn above | Gridlines and ticks drawn below | Z-order of the axis |
|---|---|---|---|
True |
Nothing in the Axes | Patches (bars, spans, filled areas) and lines and markers | 0.5 |
"line" |
Patches | Lines and markers | 1.5 |
False |
Patches and lines | Nothing in the Axes | 2.5 |
The default z-order of patches is 1 and of lines and markers is 2, which explains the middle row. In "line" mode the grid sits between those two layers, so it stays visible over a bar but does not cross a line or marker.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Choose the mode by the effect you want:
Trueis the usual choice for bar charts and shaded regions. The grid recedes behind both fills and data lines."line"keeps the grid visible through bars while leaving lines and markers clean. This is the Matplotlib default.Falseplaces the grid over everything, which is useful only when the gridlines are meant to read as an overlay, such as a reference scale on a heatmap-style figure. Expect it to reduce the contrast of the data beneath it.
Set the mode once per Axes, after plotting or before, since it applies to the whole axis:
ax.set_axisbelow(True)
If none of the three modes gives the layering you need, the Axes.grid documentation points to setting the z-order on the axis itself, which gives finer control than the three named modes.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Defaults and version differences
Matplotlib’s configuration documentation lists the rcParams defaults that govern these settings:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
axes.gridisFalse, so no grid appears unless you request one.axes.grid.axisis"both", so a grid request without anaxisargument covers both directions.axes.grid.whichis"major".axes.axisbelowis"line", which is why gridlines appear over bars by default.
The method pages cited here were versioned differently when checked. The Axes.grid page and the Axes API index were in the 3.11.2 stable documentation, and the set_axisbelow page was in the 3.10.0 documentation. The arguments and z-order values described above are the ones in those pages. If your installed version differs, check matplotlib.__version__ and the matching documentation before relying on exact behavior.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
In practice, the most reliable way to match a chart to a version is to set the grid and layering explicitly in code rather than rely on the rcParams defaults, since a shared stylesheet or a changed axes.axisbelow value will change the result without any change to the plotting call.
Quick Recap
“
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




