X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions doc/users/whats_new/ticks_rcparams.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
New rcParams
------------

The parameters `xtick.top`, `xtick.bottom`, `ytick.left`
and `ytick.right` were added to control where the ticks
are drawn.
The parameters ``xtick.top``, ``xtick.bottom``, ``ytick.left``
and ``ytick.right`` were added to control where the ticks
are drawn.

``hist.bins`` to control the default number of bins to use in
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is inconsistency with notation for the rcparams. Here, double backticks are used. Above, single backticks are used.

`~matplotlib.axes.Axes.hist`. This can be an `int`, a list of floats, or
``'auto'`` if numpy >= 1.11 is installed.
2 changes: 2 additions & 0 deletions lib/matplotlib/mpl-data/stylelib/classic.mplstyle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ patch.facecolor : b
patch.edgecolor : k
patch.antialiased : True # render patches in antialiased (no jaggies)

hist.bins : 10

### FONT
#
# font properties used by text.Text. See
Expand Down
19 changes: 18 additions & 1 deletion lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,23 @@ def validate_cycler(s):
return cycler_inst


def validate_hist_bins(s):
if isinstance(s, six.text_type) and s == 'auto':
return s
try:
return int(s)
except (TypeError, ValueError):
pass

try:
return validate_floatlist(s)
except ValueError:
pass

raise ValueError("'hist.bins' must be 'auto', an int or " +
"a sequence of floats")


# a map from key -> value, converter
defaultParams = {
'backend': ['Agg', validate_backend], # agg is certainly
Expand Down Expand Up @@ -814,7 +831,7 @@ def validate_cycler(s):
'patch.antialiased': [True, validate_bool], # antialiased (no jaggies)

## Histogram properties
'hist.bins': [10, validate_any],
'hist.bins': [10, validate_hist_bins],

## Boxplot properties
'boxplot.notch': [False, validate_bool],
Expand Down
15 changes: 13 additions & 2 deletions lib/matplotlib/tests/test_rcparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
validate_nseq_int,
validate_nseq_float,
validate_cycler,
validate_hatch)
validate_hatch,
validate_hist_bins)


mpl.rc('text', usetex=False)
Expand Down Expand Up @@ -363,7 +364,17 @@ def test_validators():
),
'fail': (('fish', ValueError),
),
}
},
{'validator': validate_hist_bins,
'success': (('auto', 'auto'),
('10', 10),
('1, 2, 3', [1, 2, 3]),
([1, 2, 3], [1, 2, 3]),
(np.arange(15), np.arange(15))
),
'fail': (('aardvark', ValueError),
)
}
)

for validator_dict in validation_tests:
Expand Down
X Tutup