2
2
unicode_literals )
3
3
4
4
import six
5
- from six .moves import reduce , xrange , zip
5
+ from six .moves import reduce , xrange , zip , zip_longest
6
6
7
7
import math
8
8
import warnings
9
- import itertools
10
9
11
10
import numpy as np
12
11
from numpy import ma
@@ -5416,14 +5415,16 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5416
5415
Input values, this takes either a single array or a sequency of
5417
5416
arrays which are not required to be of the same length
5418
5417
5419
- bins : integer or array_like, optional, default: 10
5418
+ bins : integer or array_like, optional
5420
5419
If an integer is given, `bins + 1` bin edges are returned,
5421
5420
consistently with :func:`numpy.histogram` for numpy version >=
5422
5421
1.3.
5423
5422
5424
5423
Unequally spaced bins are supported if `bins` is a sequence.
5425
5424
5426
- range : tuple, optional, default: None
5425
+ default is 10
5426
+
5427
+ range : tuple or None, optional
5427
5428
The lower and upper range of the bins. Lower and upper outliers
5428
5429
are ignored. If not provided, `range` is (x.min(), x.max()). Range
5429
5430
has no effect if `bins` is a sequence.
@@ -5432,20 +5433,26 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5432
5433
is based on the specified bin range instead of the
5433
5434
range of x.
5434
5435
5435
- normed : boolean, optional, default: False
5436
+ Default is ``None``
5437
+
5438
+ normed : boolean, optional
5436
5439
If `True`, the first element of the return tuple will
5437
5440
be the counts normalized to form a probability density, i.e.,
5438
5441
``n/(len(x)`dbin)``, i.e., the integral of the histogram will sum
5439
5442
to 1. If *stacked* is also *True*, the sum of the histograms is
5440
5443
normalized to 1.
5441
5444
5442
- weights : array_like, shape (n, ), optional, default: None
5445
+ Default is ``False``
5446
+
5447
+ weights : (n, ) array_like or None, optional
5443
5448
An array of weights, of the same shape as `x`. Each value in `x`
5444
5449
only contributes its associated weight towards the bin count
5445
5450
(instead of 1). If `normed` is True, the weights are normalized,
5446
5451
so that the integral of the density over the range remains 1.
5447
5452
5448
- cumulative : boolean, optional, default : False
5453
+ Default is ``None``
5454
+
5455
+ cumulative : boolean, optional
5449
5456
If `True`, then a histogram is computed where each bin gives the
5450
5457
counts in that bin plus all bins for smaller values. The last bin
5451
5458
gives the total number of datapoints. If `normed` is also `True`
@@ -5455,13 +5462,17 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5455
5462
`True`, then the histogram is normalized such that the first bin
5456
5463
equals 1.
5457
5464
5458
- bottom : array_like, scalar, or None, default: None
5465
+ Default is ``False``
5466
+
5467
+ bottom : array_like, scalar, or None
5459
5468
Location of the bottom baseline of each bin. If a scalar,
5460
5469
the base line for each bin is shifted by the same amount.
5461
5470
If an array, each bin is shifted independently and the length
5462
5471
of bottom must match the number of bins. If None, defaults to 0.
5463
5472
5464
- histtype : ['bar' | 'barstacked' | 'step' | 'stepfilled'], optional
5473
+ Default is ``None``
5474
+
5475
+ histtype : {'bar', 'barstacked', 'step', 'stepfilled'}, optional
5465
5476
The type of histogram to draw.
5466
5477
5467
5478
- 'bar' is a traditional bar-type histogram. If multiple data
@@ -5476,7 +5487,9 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5476
5487
- 'stepfilled' generates a lineplot that is by default
5477
5488
filled.
5478
5489
5479
- align : ['left' | 'mid' | 'right'], optional, default: 'mid'
5490
+ Default is 'bar'
5491
+
5492
+ align : {'left', 'mid', 'right'}, optional
5480
5493
Controls how the histogram is plotted.
5481
5494
5482
5495
- 'left': bars are centered on the left bin edges.
@@ -5485,34 +5498,47 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5485
5498
5486
5499
- 'right': bars are centered on the right bin edges.
5487
5500
5488
- orientation : ['horizontal' | 'vertical'], optional
5501
+ Default is 'mid'
5502
+
5503
+ orientation : {'horizontal', 'vertical'}, optional
5489
5504
If 'horizontal', `~matplotlib.pyplot.barh` will be used for
5490
5505
bar-type histograms and the *bottom* kwarg will be the left edges.
5491
5506
5492
- rwidth : scalar, optional, default: None
5507
+ rwidth : scalar or None, optional
5493
5508
The relative width of the bars as a fraction of the bin width. If
5494
- `None`, automatically compute the width. Ignored if `histtype` =
5495
- 'step' or 'stepfilled'.
5509
+ `None`, automatically compute the width.
5496
5510
5497
- log : boolean, optional, default : False
5511
+ Ignored if `histtype` is 'step' or 'stepfilled'.
5512
+
5513
+ Default is ``None``
5514
+
5515
+ log : boolean, optional
5498
5516
If `True`, the histogram axis will be set to a log scale. If `log`
5499
5517
is `True` and `x` is a 1D array, empty bins will be filtered out
5500
5518
and only the non-empty (`n`, `bins`, `patches`) will be returned.
5501
5519
5502
- color : color or array_like of colors, optional, default: None
5520
+ Default is ``False``
5521
+
5522
+ color : color or array_like of colors or None, optional
5503
5523
Color spec or sequence of color specs, one per dataset. Default
5504
5524
(`None`) uses the standard line color sequence.
5505
5525
5506
- label : string, optional, default: ''
5526
+ Default is ``None``
5527
+
5528
+ label : string or None, optional
5507
5529
String, or sequence of strings to match multiple datasets. Bar
5508
5530
charts yield multiple patches per dataset, but only the first gets
5509
5531
the label, so that the legend command will work as expected.
5510
5532
5511
- stacked : boolean, optional, default : False
5533
+ default is ``None``
5534
+
5535
+ stacked : boolean, optional
5512
5536
If `True`, multiple data are stacked on top of each other If
5513
5537
`False` multiple data are aranged side by side if histtype is
5514
5538
'bar' or on top of each other if histtype is 'step'
5515
5539
5540
+ Default is ``False``
5541
+
5516
5542
Returns
5517
5543
-------
5518
5544
n : array or list of arrays
@@ -5868,16 +5894,10 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5868
5894
labels = [None ]
5869
5895
elif is_string_like (label ):
5870
5896
labels = [label ]
5871
- elif is_sequence_of_strings (label ):
5872
- labels = list (label )
5873
5897
else :
5874
- raise ValueError (
5875
- 'invalid label: must be string or sequence of strings' )
5876
-
5877
- if len (labels ) < nx :
5878
- labels += [None ] * (nx - len (labels ))
5898
+ labels = [str (lab ) for lab in label ]
5879
5899
5880
- for (patch , lbl ) in zip (patches , labels ):
5900
+ for (patch , lbl ) in zip_longest (patches , labels , fillvalue = None ):
5881
5901
if patch :
5882
5902
p = patch [0 ]
5883
5903
p .update (kwargs )
0 commit comments