8000 Draw unfilled hist()s with the zorder of lines. · matplotlib/matplotlib@6cb7e8d · GitHub
[go: up one dir, main page]

Skip to content

Commit 6cb7e8d

Browse files
committed
Draw unfilled hist()s with the zorder of lines.
Unfilled hist()s (`histtype="step"`) are technically drawn as Patches with `fill=False`, but they are effectively lines and should therefore be drawn above gridlines (like Line2D), not below (like Patch). Change their default zorder accordingly.
1 parent 3232f58 commit 6cb7e8d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/api/api_changes_3.3/behaviour.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,8 @@ wx Timer interval
181181
~~~~~~~~~~~~~~~~~
182182
Setting the timer interval on a not-yet-started ``TimerWx`` won't start it
183183
anymore.
184+
185+
"step"-type histograms default to the zorder of `.Line2D`
186+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
187+
This ensures that they go above gridlines by default. The old ``zorder`` can
188+
be kept by passing it as a keyword argument to `.Axes.hist`.

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6769,7 +6769,8 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
67696769
closed=True if fill else None,
67706770
facecolor=c,
67716771
edgecolor=None if fill else c,
6772-
fill=fill if fill else None))
6772+
fill=fill if fill else None,
6773+
zorder=None if fill else mlines.Line2D.zorder))
67736774
for patch_list in patches:
67746775
for patch in patch_list:
67756776
if orientation == 'vertical':

0 commit comments

Comments
 (0)
0