From cfdfcb401882219191360ec7ff76737d6e1ddb3c Mon Sep 17 00:00:00 2001 From: thoo Date: Thu, 18 Oct 2018 19:32:04 -0400 Subject: [PATCH 01/10] Add density in hist2d --- lib/matplotlib/axes/_axes.py | 26 +++++++++++-- lib/matplotlib/pyplot.py | 72 ++++++++++++++---------------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index aae423b65cc3..d64f8a0e15f8 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6780,8 +6780,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None, return tops, bins, cbook.silent_list('Lists of Patches', patches) @_preprocess_data(replace_names=["x", "y", "weights"], label_namer=None) - def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None, - cmin=None, cmax=None, **kwargs): + def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, + cmin=None, cmax=None, normed=None, **kwargs): """ Make a 2D histogram plot. @@ -6814,8 +6814,14 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None, xmax], [ymin, ymax]]``. All values outside of this range will be considered outliers and not tallied in the histogram. - normed : bool, optional, default: False - Normalize histogram. + density : boolean, optional + If False, the default, returns the number of samples in each bin. + If True, returns the probability *density* function at the bin, + ``bin_count / sample_count / bin_area``. + Default is ``None`` for both *normed* and *density*. If either is + set, then that value will be used. If neither are set, then the + args will be treated as ``False``. + If both *density* and *normed* are set an error is raised. weights : array_like, shape (n, ), optional, default: None An array of values w_i weighing each sample (x_i, y_i). @@ -6830,6 +6836,9 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None, to none before passing to imshow) and these count values in the return value count histogram will also be set to nan upon return + normed : bool, optional, default: None + Deprecated; use the density keyword argument instead. + Returns ------- h : 2D array @@ -6873,6 +6882,15 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None, `.colors.PowerNorm`. """ + if density is not None and normed is not None: + raise ValueError("kwargs 'density' and 'normed' cannot be used " + "simultaneously. Please only use 'density', " + "since 'normed' is deprecated.") + if normed is not None: + cbook.warn_deprecated("2.1", name="'normed'", obj_type="kwarg", + alternative="'density'", removal="3.1") + + normed = bool(density) or bool(normed) h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range, normed=normed, weights=weights) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 6ceced49285c..af2c80d1bc3f 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2379,8 +2379,8 @@ def angle_spectrum( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.annotate) -def annotate(s, xy, *args, **kwargs): - return gca().annotate(s, xy, *args, **kwargs) +def annotate(*args, **kwargs): + return gca().annotate(*args, **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2427,12 +2427,10 @@ def axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.bar) -def bar( - x, height, width=0.8, bottom=None, *, align='center', - data=None, **kwargs): +def bar(*args, data=None, **kwargs): return gca().bar( - x, height, width=width, bottom=bottom, align=align, - **({"data": data} if data is not None else {}), **kwargs) + *args, **({"data": data} if data is not None else {}), + **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2444,9 +2442,8 @@ def barbs(*args, data=None, **kw): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.barh) -def barh(y, width, height=0.8, left=None, *, align='center', **kwargs): - return gca().barh( - y, width, height=height, left=left, align=align, **kwargs) +def barh(*args, **kwargs): + return gca().barh(*args, **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2710,8 +2707,8 @@ def magnitude_spectrum( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.margins) -def margins(*margins, x=None, y=None, tight=True): - return gca().margins(*margins, x=x, y=y, tight=tight) +def margins(*args, **kw): + return gca().margins(*args, **kw) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2728,12 +2725,9 @@ def minorticks_on(): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @_autogen_docstring(Axes.pcolor) -def pcolor( - *args, alpha=None, norm=None, cmap=None, vmin=None, - vmax=None, data=None, **kwargs): +def pcolor(*args, data=None, **kwargs): __ret = gca().pcolor( - *args, alpha=alpha, norm=norm, cmap=cmap, vmin=vmin, - vmax=vmax, **({"data": data} if data is not None else {}), + *args, **({"data": data} if data is not None else {}), **kwargs) sci(__ret) return __ret @@ -2741,14 +2735,10 @@ def pcolor( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @_autogen_docstring(Axes.pcolormesh) -def pcolormesh( - *args, alpha=None, norm=None, cmap=None, vmin=None, - vmax=None, shading='flat', antialiased=False, data=None, - **kwargs): +def pcolormesh(*args, data=None, **kwargs): __ret = gca().pcolormesh( - *args, alpha=alpha, norm=norm, cmap=cmap, vmin=vmin, - vmax=vmax, shading=shading, antialiased=antialiased, - **({"data": data} if data is not None else {}), **kwargs) + *args, **({"data": data} if data is not None else {}), + **kwargs) sci(__ret) return __ret @@ -2783,10 +2773,10 @@ def pie( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.plot) -def plot(*args, scalex=True, scaley=True, data=None, **kwargs): +def plot(*args, data=None, **kwargs): return gca().plot( - *args, scalex=scalex, scaley=scaley, **({"data": data} if data - is not None else {}), **kwargs) + *args, **({"data": data} if data is not None else {}), + **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2823,8 +2813,8 @@ def quiver(*args, data=None, **kw): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.quiverkey) -def quiverkey(Q, X, Y, U, label, **kw): - return gca().quiverkey(Q, X, Y, U, label, **kw) +def quiverkey(*args, **kw): + return gca().quiverkey(*args, **kw) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2893,21 +2883,18 @@ def stackplot(x, *args, data=None, **kwargs): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.stem) -def stem( - *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, - label=None, data=None): +def stem(*args, data=None, **kwargs): return gca().stem( - *args, linefmt=linefmt, markerfmt=markerfmt, basefmt=basefmt, - bottom=bottom, label=label, **({"data": data} if data is not - None else {})) + *args, **({"data": data} if data is not None else {}), + **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.step) -def step(x, y, *args, where='pre', data=None, **kwargs): +def step(x, y, *args, data=None, **kwargs): return gca().step( - x, y, *args, where=where, **({"data": data} if data is not - None else {}), **kwargs) + x, y, *args, **({"data": data} if data is not None else {}), + **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2949,13 +2936,8 @@ def tick_params(axis='both', **kwargs): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.ticklabel_format) -def ticklabel_format( - *, axis='both', style='', scilimits=None, useOffset=None, - useLocale=None, useMathText=None): - return gca().ticklabel_format( - axis=axis, style=style, scilimits=scilimits, - useOffset=useOffset, useLocale=useLocale, - useMathText=useMathText) +def ticklabel_format(**kwargs): + return gca().ticklabel_format(**kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. From 56385a9d461607ff37e5d371b1dab941df7b46b1 Mon Sep 17 00:00:00 2001 From: thoo Date: Thu, 18 Oct 2018 22:01:25 -0400 Subject: [PATCH 02/10] regenerate pyplot --- lib/matplotlib/pyplot.py | 72 +++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 27 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index af2c80d1bc3f..6ceced49285c 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2379,8 +2379,8 @@ def angle_spectrum( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.annotate) -def annotate(*args, **kwargs): - return gca().annotate(*args, **kwargs) +def annotate(s, xy, *args, **kwargs): + return gca().annotate(s, xy, *args, **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2427,10 +2427,12 @@ def axvspan(xmin, xmax, ymin=0, ymax=1, **kwargs): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.bar) -def bar(*args, data=None, **kwargs): +def bar( + x, height, width=0.8, bottom=None, *, align='center', + data=None, **kwargs): return gca().bar( - *args, **({"data": data} if data is not None else {}), - **kwargs) + x, height, width=width, bottom=bottom, align=align, + **({"data": data} if data is not None else {}), **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2442,8 +2444,9 @@ def barbs(*args, data=None, **kw): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.barh) -def barh(*args, **kwargs): - return gca().barh(*args, **kwargs) +def barh(y, width, height=0.8, left=None, *, align='center', **kwargs): + return gca().barh( + y, width, height=height, left=left, align=align, **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2707,8 +2710,8 @@ def magnitude_spectrum( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.margins) -def margins(*args, **kw): - return gca().margins(*args, **kw) +def margins(*margins, x=None, y=None, tight=True): + return gca().margins(*margins, x=x, y=y, tight=tight) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2725,9 +2728,12 @@ def minorticks_on(): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @_autogen_docstring(Axes.pcolor) -def pcolor(*args, data=None, **kwargs): +def pcolor( + *args, alpha=None, norm=None, cmap=None, vmin=None, + vmax=None, data=None, **kwargs): __ret = gca().pcolor( - *args, **({"data": data} if data is not None else {}), + *args, alpha=alpha, norm=norm, cmap=cmap, vmin=vmin, + vmax=vmax, **({"data": data} if data is not None else {}), **kwargs) sci(__ret) return __ret @@ -2735,10 +2741,14 @@ def pcolor(*args, data=None, **kwargs): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @_autogen_docstring(Axes.pcolormesh) -def pcolormesh(*args, data=None, **kwargs): +def pcolormesh( + *args, alpha=None, norm=None, cmap=None, vmin=None, + vmax=None, shading='flat', antialiased=False, data=None, + **kwargs): __ret = gca().pcolormesh( - *args, **({"data": data} if data is not None else {}), - **kwargs) + *args, alpha=alpha, norm=norm, cmap=cmap, vmin=vmin, + vmax=vmax, shading=shading, antialiased=antialiased, + **({"data": data} if data is not None else {}), **kwargs) sci(__ret) return __ret @@ -2773,10 +2783,10 @@ def pie( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.plot) -def plot(*args, data=None, **kwargs): +def plot(*args, scalex=True, scaley=True, data=None, **kwargs): return gca().plot( - *args, **({"data": data} if data is not None else {}), - **kwargs) + *args, scalex=scalex, scaley=scaley, **({"data": data} if data + is not None else {}), **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2813,8 +2823,8 @@ def quiver(*args, data=None, **kw): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.quiverkey) -def quiverkey(*args, **kw): - return gca().quiverkey(*args, **kw) +def quiverkey(Q, X, Y, U, label, **kw): + return gca().quiverkey(Q, X, Y, U, label, **kw) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2883,18 +2893,21 @@ def stackplot(x, *args, data=None, **kwargs): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.stem) -def stem(*args, data=None, **kwargs): +def stem( + *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0, + label=None, data=None): return gca().stem( - *args, **({"data": data} if data is not None else {}), - **kwargs) + *args, linefmt=linefmt, markerfmt=markerfmt, basefmt=basefmt, + bottom=bottom, label=label, **({"data": data} if data is not + None else {})) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.step) -def step(x, y, *args, data=None, **kwargs): +def step(x, y, *args, where='pre', data=None, **kwargs): return gca().step( - x, y, *args, **({"data": data} if data is not None else {}), - **kwargs) + x, y, *args, where=where, **({"data": data} if data is not + None else {}), **kwargs) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @@ -2936,8 +2949,13 @@ def tick_params(axis='both', **kwargs): # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @docstring.copy_dedent(Axes.ticklabel_format) -def ticklabel_format(**kwargs): - return gca().ticklabel_format(**kwargs) +def ticklabel_format( + *, axis='both', style='', scilimits=None, useOffset=None, + useLocale=None, useMathText=None): + return gca().ticklabel_format( + axis=axis, style=style, scilimits=scilimits, + useOffset=useOffset, useLocale=useLocale, + useMathText=useMathText) # Autogenerated by boilerplate.py. Do not edit as changes will be lost. From 03ad3d879cf195e5196b380eb9aee856125189ac Mon Sep 17 00:00:00 2001 From: thoo Date: Thu, 18 Oct 2018 23:35:37 -0400 Subject: [PATCH 03/10] regenerate pyplot with correct version --- lib/matplotlib/pyplot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 6ceced49285c..f017ed540cd3 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -2640,12 +2640,12 @@ def hist( # Autogenerated by boilerplate.py. Do not edit as changes will be lost. @_autogen_docstring(Axes.hist2d) def hist2d( - x, y, bins=10, range=None, normed=False, weights=None, - cmin=None, cmax=None, *, data=None, **kwargs): + x, y, bins=10, range=None, density=None, weights=None, + cmin=None, cmax=None, normed=None, *, data=None, **kwargs): __ret = gca().hist2d( - x, y, bins=bins, range=range, normed=normed, weights=weights, - cmin=cmin, cmax=cmax, **({"data": data} if data is not None - else {}), **kwargs) + x, y, bins=bins, range=range, density=density, + weights=weights, cmin=cmin, cmax=cmax, normed=normed, + **({"data": data} if data is not None else {}), **kwargs) sci(__ret[-1]) return __ret From ed6d3e650b008ae04ef6b1716def3900fb820860 Mon Sep 17 00:00:00 2001 From: thoo Date: Sat, 20 Oct 2018 10:20:18 -0400 Subject: [PATCH 04/10] Fix deprecated warnings and description in density --- lib/matplotlib/axes/_axes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index d64f8a0e15f8..bee769ca6dad 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6815,7 +6815,7 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, considered outliers and not tallied in the histogram. density : boolean, optional - If False, the default, returns the number of samples in each bin. + If False, the default, plots and returns the number of samples in each bin. If True, returns the probability *density* function at the bin, ``bin_count / sample_count / bin_area``. Default is ``None`` for both *normed* and *density*. If either is @@ -6887,8 +6887,8 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, "simultaneously. Please only use 'density', " "since 'normed' is deprecated.") if normed is not None: - cbook.warn_deprecated("2.1", name="'normed'", obj_type="kwarg", - alternative="'density'", removal="3.1") + cbook.warn_deprecated("3.1", name="'normed'", obj_type="kwarg", + alternative="'density") normed = bool(density) or bool(normed) h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range, From f645179928e3f9a72173814eef5261121817d0b7 Mon Sep 17 00:00:00 2001 From: thoo Date: Sat, 20 Oct 2018 10:45:46 -0400 Subject: [PATCH 05/10] Fix long string --- lib/matplotlib/axes/_axes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index bee769ca6dad..0305e466a3d2 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6815,9 +6815,9 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, considered outliers and not tallied in the histogram. density : boolean, optional - If False, the default, plots and returns the number of samples in each bin. - If True, returns the probability *density* function at the bin, - ``bin_count / sample_count / bin_area``. + If False, the default, plots and returns the number of samples + in each bin. If True, returns the probability *density* + function at the bin, ``bin_count / sample_count / bin_area``. Default is ``None`` for both *normed* and *density*. If either is set, then that value will be used. If neither are set, then the args will be treated as ``False``. From 9c538e1b19b01245bc104d51db6b8a44ad36d352 Mon Sep 17 00:00:00 2001 From: thoo Date: Sun, 21 Oct 2018 02:42:18 -0400 Subject: [PATCH 06/10] Add description about density and tests --- lib/matplotlib/axes/_axes.py | 3 +++ lib/matplotlib/tests/test_axes.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 0305e466a3d2..cd6da4907982 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6880,6 +6880,9 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, keyword argument. Likewise, power-law normalization (similar in effect to gamma correction) can be accomplished with `.colors.PowerNorm`. + - Numpy 1.15 introduced a 'density' kwarg to hist2d. Even though + Numpy 1.15 isn't required, 'density' kwarg is introduced + and passed as 'normed' to ``hist2d``. """ if density is not None and normed is not None: diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index b4879e3b208a..35d52fb3a94f 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -1672,6 +1672,30 @@ def test_hist2d(): ax.hist2d("x", "y", bins=10, data=data, rasterized=True) +@pytest.mark.parametrize('density', [False, True]) +def test_hist2d_density(density): + # Test density kwarg + x = np.random.randn(100)*2+5 + y = np.random.randn(100)-2 + fig = plt.figure() + ax = fig.add_subplot(111) + ax.hist2d(x, y, bins=10, rasterized=True, density=density) + + +@pytest.mark.parametrize('normed', [False, True]) +@pytest.mark.parametrize('density', [False, True]) +def test_hist2d_normed_density(density, normed): + # Normed and density should not be used simultaneously + x = np.random.randn(100)*2+5 + y = np.random.randn(100)-2 + fig = plt.figure() + ax = fig.add_subplot(111) + # test that kwargs normed and density cannot be set both. + with pytest.raises(ValueError, match="kwargs 'density' and 'normed'"): + ax.hist2d(x, y, bins=10, rasterized=True, + density=density, normed=normed) + + @image_comparison(baseline_images=['hist2d_transpose'], remove_text=True, style='mpl20') def test_hist2d_transpose(): From 3d030a409ed0eddabb48f461b4078eebeb5f0c17 Mon Sep 17 00:00:00 2001 From: thoo Date: Sun, 21 Oct 2018 11:35:21 -0400 Subject: [PATCH 07/10] typo --- lib/matplotlib/axes/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index cd6da4907982..af69cc493b1e 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6880,7 +6880,7 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, keyword argument. Likewise, power-law normalization (similar in effect to gamma correction) can be accomplished with `.colors.PowerNorm`. - - Numpy 1.15 introduced a 'density' kwarg to hist2d. Even though + - Numpy 1.15 introduced a 'density' kwarg to ``hist2d``. Even though Numpy 1.15 isn't required, 'density' kwarg is introduced and passed as 'normed' to ``hist2d``. """ From 61a552cd9ec57afe1ccbceb53e544d528b45307c Mon Sep 17 00:00:00 2001 From: thoo Date: Sun, 21 Oct 2018 13:47:28 -0400 Subject: [PATCH 08/10] Switch to code block python --- 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 af69cc493b1e..5b56d5859b7a 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6893,9 +6893,9 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, cbook.warn_deprecated("3.1", name="'normed'", obj_type="kwarg", alternative="'density") - normed = bool(density) or bool(normed) + density = bool(density) or bool(normed) h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range, - normed=normed, weights=weights) + density=density, weights=weights) if cmin is not None: h[h < cmin] = None From ab1765dc84a3b4149e3ce4739848275b454fb3a8 Mon Sep 17 00:00:00 2001 From: thoo Date: Sun, 21 Oct 2018 21:20:30 -0400 Subject: [PATCH 09/10] changes upon requests --- lib/matplotlib/axes/_axes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 5b56d5859b7a..9d5e7350e05d 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6838,6 +6838,9 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, normed : bool, optional, default: None Deprecated; use the density keyword argument instead. + Numpy 1.15 introduced a 'density' kwarg to ``hist2d``. Even though + Numpy 1.15 isn't required, 'density' kwarg is introduced + and passed as 'normed' to ``hist2d``. Returns ------- @@ -6880,9 +6883,6 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, keyword argument. Likewise, power-law normalization (similar in effect to gamma correction) can be accomplished with `.colors.PowerNorm`. - - Numpy 1.15 introduced a 'density' kwarg to ``hist2d``. Even though - Numpy 1.15 isn't required, 'density' kwarg is introduced - and passed as 'normed' to ``hist2d``. """ if density is not None and normed is not None: From fe40a0e6426acdedd22dcd380c0cf99a2147dd52 Mon Sep 17 00:00:00 2001 From: thoo Date: Fri, 26 Oct 2018 21:11:38 -0400 Subject: [PATCH 10/10] Fix density kwarg: --- lib/matplotlib/axes/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 9d5e7350e05d..dfa0ab608aaf 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6895,7 +6895,7 @@ def hist2d(self, x, y, bins=10, range=None, density=None, weights=None, density = bool(density) or bool(normed) h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range, - density=density, weights=weights) + normed=density, weights=weights) if cmin is not None: h[h < cmin] = None