diff --git a/lib/matplotlib/axes/_axes.py b/lib/matplotlib/axes/_axes.py index 4266cba8697b..5acd79c765c0 100644 --- a/lib/matplotlib/axes/_axes.py +++ b/lib/matplotlib/axes/_axes.py @@ -6380,7 +6380,7 @@ def hist(self, x, bins=None, range=None, density=None, weights=None, With Numpy 1.11 or newer, you can alternatively provide a string describing a binning strategy, such as 'auto', 'sturges', 'fd', - 'doane', 'scott', 'rice', 'sturges' or 'sqrt', see + 'doane', 'scott', 'rice' or 'sqrt', see `numpy.histogram`. The default is taken from :rc:`hist.bins`. diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index 767f3701e917..6271119f6583 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -914,7 +914,8 @@ def validate_cycler(s): def validate_hist_bins(s): - if cbook._str_equal(s, "auto"): + valid_strs = ["auto", "sturges", "fd", "doane", "scott", "rice", "sqrt"] + if isinstance(s, str) and s in valid_strs: return s try: return int(s) @@ -924,8 +925,8 @@ def validate_hist_bins(s): return validate_floatlist(s) except ValueError: pass - raise ValueError("'hist.bins' must be 'auto', an int or " + - "a sequence of floats") + raise ValueError("'hist.bins' must be one of {}, an int or" + " a sequence of floats".format(valid_strs)) def validate_animation_writer_path(p): diff --git a/lib/matplotlib/tests/test_rcparams.py b/lib/matplotlib/tests/test_rcparams.py index 3380308d7d81..aaf52b0246ca 100644 --- a/lib/matplotlib/tests/test_rcparams.py +++ b/lib/matplotlib/tests/test_rcparams.py @@ -321,6 +321,7 @@ def generate_validator_testcases(valid): }, {'validator': validate_hist_bins, 'success': (('auto', 'auto'), + ('fd', 'fd'), ('10', 10), ('1, 2, 3', [1, 2, 3]), ([1, 2, 3], [1, 2, 3]),