-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Minor docstring updates on binning related plot functions #10831
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
Conversation
lib/matplotlib/axes/_axes.py
Outdated
@@ -4193,7 +4193,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None, | |||
If *C* is specified, it specifies values at the coordinate | |||
(x[i],y[i]). These values are accumulated for each hexagonal | |||
bin and then reduced according to *reduce_C_function*, which | |||
defaults to numpy's mean function (np.mean). (If *C* is | |||
defaults to numpy's mean function (`numpy.mean`). (If *C* is |
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.
rephrase as
defaults to `numpy.mean`.
? (more concise but just as clear)
I wonder if that belongs to the scope of this PR, but I think that the description used for the bins parameter in For example, the following (inspired from the numpy docs) runs fine on my laptop with Matplotlib 2.1.0 and numpy 1.13 (both from conda) import numpy as np
import matplotlib.pyplot as plt
prng = np.random.RandomState(10) # deterministic random data
a = np.hstack((prng.normal(size=1000),
prng.normal(loc=5, scale=2, size=1000)))
non_auto_bins_str = ("fd", "doane", "scott", "rice", "sturges", "sqrt")
fig, axs = plt.subplots(nrows=2, ncols=3, sharex=True)
for ax, bins in zip(axs.flat, non_auto_bins_str):
ax.hist(a, bins=bins) # arguments are passed to np.histogram
ax.set_title("'{}' bins".format(bins))
fig.tight_layout()
fig.show() |
I am hesitant to document the auto-binning on histogram more than 'with a new enough version of numpy strings will work, see |
How about: 'with a new enough version of numpy, strings that specify a binning strategy are also accepted, see |
fwiw that's numpy 1.11. |
Thanks for the hint on the binning strategy. I've now written.
I think that's clear and useful, and without the danger that it will not work unexpectedly. |
defaults to numpy's mean function (np.mean). (If *C* is | ||
specified, it must also be a 1-D sequence of the same length | ||
as *x* and *y*.) | ||
defaults to `numpy.mean`. (If *C* is specified, it must also |
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.
two lines earlier: space after comma
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.
Done.
Input values | ||
|
||
bins: [None | int | [int, int] | array_like | [array, array]] | ||
bins : None or int or [int, int] or array_like or [array, array] |
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.
(int, int) or (array, array)? (feels like tuples, nor arrays)
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.
This description came from
numpy.histogram2d. I would leave it like this.
PR Summary
As part of #10148: Docstring update for
Axes.hexbin
,Axes.hist
andAxes.hist2d
.