From 40552c1a9ff2859baaa404c693f936ef0b9eac23 Mon Sep 17 00:00:00 2001 From: Raphael Erik Hviding Date: Thu, 30 Jan 2025 17:24:39 +0000 Subject: [PATCH 1/2] Normalize kwargs for hist --- lib/matplotlib/axes/_axes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 0deccae8476d..424dd45ae479 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6997,6 +6997,8 @@ def hist(self, x, bins=None, range=None, density=False, weights=None, (``plt.stairs(*np.histogram(data))``), or by setting *histtype* to 'step' or 'stepfilled' rather than 'bar' or 'barstacked'. """ + kwargs = cbook.normalize_kwargs(kwargs, mpatches.Patch) + # Avoid shadowing the builtin. bin_range = range from builtins import range From 6562e193cbac0104e04cce7b51479c3c1ad73e4c Mon Sep 17 00:00:00 2001 From: Raphael Erik Hviding Date: Tue, 11 Feb 2025 15:06:42 +0100 Subject: [PATCH 2/2] Avoid shadowing the builtin first! Co-authored-by: Elliott Sales de Andrade --- lib/matplotlib/axes/_axes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 58154fd7b7d7..ebeb2413ac52 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6997,12 +6997,12 @@ def hist(self, x, bins=None, range=None, density=False, weights=None, (``plt.stairs(*np.histogram(data))``), or by setting *histtype* to 'step' or 'stepfilled' rather than 'bar' or 'barstacked'. """ - kwargs = cbook.normalize_kwargs(kwargs, mpatches.Patch) - # Avoid shadowing the builtin. bin_range = range from builtins import range + kwargs = cbook.normalize_kwargs(kwargs, mpatches.Patch) + if np.isscalar(x): x = [x]