|
35 | 35 | from matplotlib.axes._secondary_axes import SecondaryAxis |
36 | 36 | from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer |
37 | 37 |
|
38 | | -try: |
39 | | - from numpy.lib.histograms import ( |
40 | | - histogram_bin_edges as _histogram_bin_edges) |
41 | | -except ImportError: |
42 | | - # this function is new in np 1.15 |
43 | | - def _histogram_bin_edges(arr, bins, range=None, weights=None): |
44 | | - # this in True for 1D arrays, and False for None and str |
45 | | - if np.ndim(bins) == 1: |
46 | | - return bins |
47 | | - |
48 | | - if isinstance(bins, str): |
49 | | - # rather than backporting the internals, just do the full |
50 | | - # computation. If this is too slow for users, they can |
51 | | - # update numpy, or pick a manual number of bins |
52 | | - return np.histogram(arr, bins, range, weights)[1] |
53 | | - else: |
54 | | - if bins is None: |
55 | | - # hard-code numpy's default |
56 | | - bins = 10 |
57 | | - if range is None: |
58 | | - range = np.min(arr), np.max(arr) |
59 | | - |
60 | | - return np.linspace(*range, bins + 1) |
61 | | - |
62 | 38 |
|
63 | 39 | _log = logging.getLogger(__name__) |
64 | 40 |
|
@@ -6698,8 +6674,8 @@ def hist(self, x, bins=None, range=None, density=False, weights=None, |
6698 | 6674 | _w = np.concatenate(w) |
6699 | 6675 | else: |
6700 | 6676 | _w = None |
6701 | | - |
6702 | | - bins = _histogram_bin_edges(np.concatenate(x), bins, bin_range, _w) |
| 6677 | + bins = np.histogram_bin_edges( |
| 6678 | + np.concatenate(x), bins, bin_range, _w) |
6703 | 6679 | else: |
6704 | 6680 | hist_kwargs['range'] = bin_range |
6705 | 6681 |
|
|
0 commit comments