Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce6ed74

Browse files
committed
Add a "density" kwarg to hist2d#11070
1 parent566bd8b commitce6ed74

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

‎lib/matplotlib/axes/_axes.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6778,7 +6778,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
67786778
returntops,bins,cbook.silent_list('Lists of Patches',patches)
67796779

67806780
@_preprocess_data(replace_names=["x","y","weights"],label_namer=None)
6781-
defhist2d(self,x,y,bins=10,range=None,normed=False,weights=None,
6781+
defhist2d(self,x,y,bins=10,range=None,density=None,normed=None,weights=None,
67826782
cmin=None,cmax=None,**kwargs):
67836783
"""
67846784
Make a 2D histogram plot.
@@ -6812,11 +6812,22 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,
68126812
xmax], [ymin, ymax]]``. All values outside of this range will be
68136813
considered outliers and not tallied in the histogram.
68146814
6815-
normed : bool, optional, default: False
6816-
Normalize histogram.
6815+
density : boolean, optional
6816+
If False, the default, returns the number of samples in each bin.
6817+
If True, returns the probability *density* function at the bin,
6818+
``bin_count / sample_count / bin_area``.
6819+
6820+
Default is ``None`` for both *normed* and *density*. If either is
6821+
set, then that value will be used. If neither are set, then the
6822+
args will be treated as ``False``.
6823+
If both *density* and *normed* are set an error is raised.
6824+
6825+
normed : bool, optional, default: None
6826+
Deprecated; use the density keyword argument instead.
6827+
68176828
68186829
weights : array_like, shape (n, ), optional, default: None
6819-
An array of values w_i weighing each sample (x_i, y_i).
6830+
An array of values w_i weighing each sample (x_i, y_i).
68206831
68216832
cmin : scalar, optional, default: None
68226833
All bins that has count less than cmin will not be displayed and
@@ -6870,7 +6881,16 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,
68706881
in effect to gamma correction) can be accomplished with
68716882
`.colors.PowerNorm`.
68726883
"""
6873-
6884+
ifdensityisnotNoneandnormedisnotNone:
6885+
raiseValueError("kwargs 'density' and 'normed' cannot be used "
6886+
"simultaneously. "
6887+
"Please only use 'density', since 'normed'"
6888+
"is deprecated.")
6889+
ifnormedisnotNone:
6890+
cbook.warn_deprecated("2.1",name="'normed'",obj_type="kwarg",
6891+
alternative="'density'",removal="3.1")
6892+
6893+
normed=bool(density)orbool(normed)
68746894
h,xedges,yedges=np.histogram2d(x,y,bins=bins,range=range,
68756895
normed=normed,weights=weights)
68766896

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp