Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac7bba9

Browse filesBrowse files
committed
Merge pull request #5503 from mdboom/hist-bins
Fix #4487: Take hist bins from rcParam
1 parent cbb3dc8 commit ac7bba9
Copy full SHA for ac7bba9

File tree

Expand file treeCollapse file tree

3 files changed

+16
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-3
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+8-3Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5682,7 +5682,7 @@ def table(self, **kwargs):
56825682

56835683
@unpack_labeled_data(replace_names=["x", 'weights'], label_namer="x")
56845684
@docstring.dedent_interpd
5685-
def hist(self, x, bins=10, range=None, normed=False, weights=None,
5685+
def hist(self, x, bins=None, range=None, normed=False, weights=None,
56865686
cumulative=False, bottom=None, histtype='bar', align='mid',
56875687
orientation='vertical', rwidth=None, log=False,
56885688
color=None, label=None, stacked=False,
@@ -5708,14 +5708,16 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
57085708
Input values, this takes either a single array or a sequency of
57095709
arrays which are not required to be of the same length
57105710
5711-
bins : integer or array_like, optional
5711+
bins : integer or array_like or 'auto', optional
57125712
If an integer is given, `bins + 1` bin edges are returned,
57135713
consistently with :func:`numpy.histogram` for numpy version >=
57145714
1.3.
57155715
57165716
Unequally spaced bins are supported if `bins` is a sequence.
57175717
5718-
default is 10
5718+
If Numpy 1.11 is installed, may also be ``'auto'``.
5719+
5720+
Default is taken from the rcParam ``hist.bins``.
57195721
57205722
range : tuple or None, optional
57215723
The lower and upper range of the bins. Lower and upper outliers
@@ -5877,6 +5879,9 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
58775879
if np.isscalar(x):
58785880
x = [x]
58795881

5882+
if bins is None:
5883+
bins = rcParams['hist.bins']
5884+
58805885
# xrange becomes range after 2to3
58815886
bin_range = range
58825887
range = __builtins__["range"]

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ def validate_cycler(s):
813813
'patch.facecolor': ['b', validate_color], # blue
814814
'patch.antialiased': [True, validate_bool], # antialiased (no jaggies)
815815

816+
## Histogram properties
817+
'hist.bins': [10, validate_any],
818+
816819
## Boxplot properties
817820
'boxplot.notch': [False, validate_bool],
818821
'boxplot.vertical': [True, validate_bool],

‎matplotlibrc.template

Copy file name to clipboardExpand all lines: matplotlibrc.template
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,11 @@ backend : %(backend)s
376376
### ERRORBAR PLOTS
377377
#errorbar.capsize : 3 # length of end cap on error bars in pixels
378378

379+
### HISTOGRAM PLOTS
380+
#hist.bins : 10 # The default number of histogram bins.
381+
# If Numpy 1.11 or later is
382+
# installed, may also be `auto`
383+
379384
### Agg rendering
380385
### Warning: experimental, 2008/10/10
381386
#agg.path.chunksize : 0 # 0 to disable; values in the range

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.