-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Adding density hist2d #12563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding density hist2d #12563
Changes from all commits
cfdfcb4
56385a9
03ad3d8
ed6d3e6
f645179
9c538e1
3d030a4
61a552c
ab1765d
fe40a0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, 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``. | ||
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,12 @@ 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. | ||
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 | ||
------- | ||
h : 2D array | ||
|
@@ -6873,8 +6885,17 @@ 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("3.1", name="'normed'", obj_type="kwarg", | ||
alternative="'density") | ||
|
||
density = bool(density) or bool(normed) | ||
h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should call the argument This could also use a comment in here about how we will need to switch to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with the change proposed here , but only because numpy is moving to using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you still have I think there should be a comment in the code here for future reference to explain this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I misunderstood about your comment on |
||
normed=normed, weights=weights) | ||
normed=density, weights=weights) | ||
|
||
if cmin is not None: | ||
h[h < cmin] = None | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the discussion of deprecated
normed
kwarg in the description of that kwarg?