8000 Merge pull request #5505 from tacaswell/doc_missing_hist_docs · matplotlib/matplotlib@10cb842 · GitHub
[go: up one dir, main page]

Skip to content

Commit 10cb842

Browse files
committed
Merge pull request #5505 from tacaswell/doc_missing_hist_docs
DOC: add missing whatsnew + classic style to #5503
2 parents 3814c77 + 7d8d78e commit 10cb842

File tree

4 files changed

+40
-6
lines changed

4 files changed

+40
-6
lines changed
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
New rcParams
22
------------
33

4-
The parameters `xtick.top`, `xtick.bottom`, `ytick.left`
5-
and `ytick.right` were added to control where the ticks
6-
are drawn.
4+
The parameters ``xtick.top``, ``xtick.bottom``, ``ytick.left``
5+
and ``ytick.right`` were added to control where the ticks
6+
are drawn.
7+
8+
``hist.bins`` to control the default number of bins to use in
9+
`~matplotlib.axes.Axes.hist`. This can be an `int`, a list of floats, or
10+
``'auto'`` if numpy >= 1.11 is installed.

lib/matplotlib/mpl-data/stylelib/classic.mplstyle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ patch.facecolor : b
2929
patch.edgecolor : k
3030
patch.antialiased : True # render patches in antialiased (no jaggies)
3131

32+
hist.bins : 10
33+
3234
### FONT
3335
#
3436
# font properties used by text.Text. See

lib/matplotlib/rcsetup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,23 @@ def validate_cycler(s):
770770
return cycler_inst
771771

772772

773+
def validate_hist_bins(s):
774+
if isinstance(s, six.text_type) and s == 'auto':
775+
return s
776+
try:
777+
return int(s)
778+
except (TypeError, ValueError):
779+
pass
780+
781+
try:
782+
return validate_floatlist(s)
783+
except ValueError:
784+
pass
785+
786+
raise ValueError("'hist.bins' must be 'auto', an int or " +
787+
"a sequence of floats")
788+
789+
773790
# a map from key -> value, converter
774791
defaultParams = {
775792
'backend': ['Agg', validate_backend], # agg is certainly
@@ -814,7 +831,7 @@ def validate_cycler(s):
814831
'patch.antialiased': [True, validate_bool], # antialiased (no jaggies)
815832

816833
## Histogram properties
817-
'hist.bins': [10, validate_any],
834+
'hist.bins': [10, validate_hist_bins],
818835

819836
## Boxplot properties
820837
'boxplot.notch': [False, validate_bool],

lib/matplotlib/tests/test_rcparams.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
validate_nseq_int,
2828
validate_nseq_float,
2929
validate_cycler,
30-
validate_hatch)
30+
validate_hatch,
31+
validate_hist_bins)
3132

3233

3334
mpl.rc('text', usetex=False)
@@ -363,7 +364,17 @@ def test_validators():
363364
),
364365
'fail': (('fish', ValueError),
365366
),
366-
}
367+
},
368+
{'validator': validate_hist_bins,
369+
'success': (('auto', 'auto'),
370+
('10', 10),
371+
('1, 2, 3', [1, 2, 3]),
372+
([1, 2, 3], [1, 2, 3]),
373+
(np.arange(15), np.arange(15))
374+
),
375+
'fail': (('aardvark', ValueError),
376+
)
377+
}
367378
)
368379

369380
for validator_dict in validation_tests:

0 commit comments

Comments
 (0)
0