Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Add hist.histtype rcParam.
histtype='stepfilled' is significantly faster than the current default
('bar') for large numbers of bins, but changing the default would cause
backcompat problems.

The 'hist.histtype' rcParam is introduced with the explicit intent of
preparing this transition (later making 'stepfilled' (or perhaps 'step')
the default and then deprecating the rcParam, to avoid neverending
growth of the rcParam list).
  • Loading branch information
anntzer committed Oct 11, 2018
commit a770066b3316a5d1e1270e511843e5a1c59e4822
7 changes: 7 additions & 0 deletions doc/users/next_whats_new/2018-10-11-AL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Introduction of :rc:`hist.histtype`
```````````````````````````````````

The default value of the ``histtype`` argument to `Axes.hist()` can now be
controlled using :rc:`hist.histtype`. For large numbers of bins, setting
this value to 'step' or 'stepfilled' can result in significant performance
improvements over 'bar', the current default.
9 changes: 7 additions & 2 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6259,7 +6259,7 @@ def table(self, **kwargs):

@_preprocess_data(replace_names=["x", 'weights'], label_namer="x")
def hist(self, x, bins=None, range=None, density=None, weights=None,
cumulative=False, bottom=None, histtype='bar', align='mid',
cumulative=False, bottom=None, histtype=None, align='mid',
orientation='vertical', rwidth=None, log=False,
color=None, label=None, stacked=False, normed=None,
**kwargs):
Expand Down Expand Up @@ -6375,7 +6375,10 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
- 'step' generates a lineplot that is by default unfilled.
- 'stepfilled' generates a lineplot that is by default filled.

Default is 'bar'.
For large numbers of bins, 'step' and 'stepfilled' can be
significantly faster than 'bar' and 'barstacked'.

Default is taken from :rc:`hist.histtype`.

align : {'left', 'mid', 'right'}, optional
Controls how the histogram is plotted.
Expand Down Expand Up @@ -6471,6 +6474,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,

if bins is None:
bins = rcParams['hist.bins']
if histtype is None:
histtype = rcParams['hist.histtype']

# Validate string inputs here so we don't have to clutter
# subsequent code.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2625,7 +2625,7 @@ def hexbin(
@docstring.copy_dedent(Axes.hist)
def hist(
x, bins=None, range=None, density=None, weights=None,
cumulative=False, bottom=None, histtype='bar', align='mid',
cumulative=False, bottom=None, histtype=None, align='mid',
orientation='vertical', rwidth=None, log=False, color=None,
label=None, stacked=False, normed=None, *, data=None,
**kwargs):
Expand Down
4 changes: 4 additions & 0 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,10 @@ def _validate_linestyle(ls):

## Histogram properties
'hist.bins': [10, validate_hist_bins],
'hist.histtype': [
'bar',
ValidateInStrings(
'histtype', ['bar', 'barstacked', 'step', 'stepfilled'])],

## Boxplot properties
'boxplot.notch': [False, validate_bool],
Expand Down
1 change: 1 addition & 0 deletions matplotlibrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@
#hist.bins : 10 ## The default number of histogram bins.
## If Numpy 1.11 or later is
## installed, may also be `auto`
#hist.histtype : bar ## The default histtype.

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.

It would be useful to list the options here

## The default histtype. One of 'bar', 'barstacked', 'step', 'stepfilled'.


#### SCATTER PLOTS
#scatter.marker : o ## The default marker type for scatter plots.
Expand Down