8000 Backport PR #13995: DOC: explain zorder for gridlines in grid docstring · matplotlib/matplotlib@f128e0a · GitHub
[go: up one dir, main page]

Skip to content

Commit f128e0a

Browse files
dstansbyMeeseeksDev[bot]
authored andcommitted
Backport PR #13995: DOC: explain zorder for gridlines in grid docstring
1 parent 1f9b21c commit f128e0a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,8 +2716,9 @@ def set_axisbelow(self, b):
27162716
Possible values:
27172717
27182718
- *True* (zorder = 0.5): Ticks and gridlines are below all Artists.
2719-
- 'line' (zorder = 1.5): Ticks and gridlines are above patches (
2720-
e.g. rectangles) but still below lines / markers.
2719+
- 'line' (zorder = 1.5): Ticks and gridlines are above patches
2720+
(e.g. rectangles, with default zorder = 1) but still below lines
2721+
and markers (with their default zorder = 2).
27212722
- *False* (zorder = 2.5): Ticks and gridlines are above patches
27222723
and lines / markers.
27232724
@@ -2745,17 +2746,17 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
27452746
27462747
Parameters
27472748
----------
2748-
b : bool or None
2749+
b : bool or None, optional
27492750
Whether to show the grid lines. If any *kwargs* are supplied,
27502751
it is assumed you want the grid on and *b* will be set to True.
27512752
27522753
If *b* is *None* and there are no *kwargs*, this toggles the
27532754
visibility of the lines.
27542755
2755-
which : {'major', 'minor', 'both'}
2756+
which : {'major', 'minor', 'both'}, optional
27562757
The grid lines to apply the changes on.
27572758
2758-
axis : {'both', 'x', 'y'}
2759+
axis : {'both', 'x', 'y'}, optional
27592760
The axis to apply the changes on.
27602761
27612762
**kwargs : `.Line2D` properties
@@ -2769,7 +2770,11 @@ def grid(self, b=None, which='major', axis='both', **kwargs):
27692770
27702771
Notes
27712772
-----
2772-
The grid will be drawn according to the axes' zorder and not its own.
2773+
The axis is drawn as a unit, so the effective zorder for drawing the
2774+
grid is determined by the zorder of each axis, not by the zorder of the
2775+
`.Line2D` objects comprising the grid. Therefore, to set grid zorder,
2776+
use `.set_axisbelow` or, for more control, call the
2777+
`~matplotlib.axis.Axis.set_zorder` method of each axis.
27732778
"""
27742779
if len(kwargs):
27752780
b = True

0 commit comments

Comments
 (0)
0