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
@@ -5401,14 +5400,16 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5401
5400
Input values, this takes either a single array or a sequency of
5402
5401
arrays which are not required to be of the same length
5403
5402
5404
- bins : integer or array_like, optional, default: 10
5403
+ bins : integer or array_like, optional
5405
5404
If an integer is given, `bins + 1` bin edges are returned,
5406
5405
consistently with :func:`numpy.histogram` for numpy version >=
5407
5406
1.3.
5408
5407
5409
5408
Unequally spaced bins are supported if `bins` is a sequence.
5410
5409
5411
- range : tuple, optional, default: None
5410
+ default is 10
5411
+
5412
+ range : tuple or None, optional
5412
5413
The lower and upper range of the bins. Lower and upper outliers
5413
5414
are ignored. If not provided, `range` is (x.min(), x.max()). Range
5414
5415
has no effect if `bins` is a sequence.
@@ -5417,20 +5418,26 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5417
5418
is based on the specified bin range instead of the
5418
5419
range of x.
5419
5420
5420
- normed : boolean, optional, default: False
5421
+ Default is ``None``
5422
+
5423
+ normed : boolean, optional
5421
5424
If `True`, the first element of the return tuple will
5422
5425
be the counts normalized to form a probability density, i.e.,
5423
5426
``n/(len(x)`dbin)``, i.e., the integral of the histogram will sum
5424
5427
to 1. If *stacked* is also *True*, the sum of the histograms is
5425
5428
normalized to 1.
5426
5429
5427
- weights : array_like, shape (n, ), optional, default: None
5430
+ Default is ``False``
5431
+
5432
+ weights : (n, ) array_like or None, optional
5428
5433
An array of weights, of the same shape as `x`. Each value in `x`
5429
5434
only contributes its associated weight towards the bin count
5430
5435
(instead of 1). If `normed` is True, the weights are normalized,
5431
5436
so that the integral of the density over the range remains 1.
5432
5437
5433
- cumulative : boolean, optional, default : False
5438
+ Default is ``None``
5439
+
5440
+ cumulative : boolean, optional
5434
5441
If `True`, then a histogram is computed where each bin gives the
5435
5442
counts in that bin plus all bins for smaller values. The last bin
5436
5443
gives the total number of datapoints. If `normed` is also `True`
@@ -5440,13 +5447,17 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5440
5447
`True`, then the histogram is normalized such that the first bin
5441
5448
equals 1.
5442
5449
5443
- bottom : array_like, scalar, or None, default: None
5450
+ Default is ``False``
5451
+
5452
+ bottom : array_like, scalar, or None
5444
5453
Location of the bottom baseline of each bin. If a scalar,
5445
5454
the base line for each bin is shifted by the same amount.
5446
5455
If an array, each bin is shifted independently and the length
5447
5456
of bottom must match the number of bins. If None, defaults to 0.
5448
5457
5449
- histtype : ['bar' | 'barstacked' | 'step' | 'stepfilled'], optional
5458
+ Default is ``None``
5459
+
5460
+ histtype : {'bar', 'barstacked', 'step', 'stepfilled'}, optional
5450
5461
The type of histogram to draw.
5451
5462
5452
5463
- 'bar' is a traditional bar-type histogram. If multiple data
@@ -5461,7 +5472,9 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5461
5472
- 'stepfilled' generates a lineplot that is by default
5462
5473
filled.
5463
5474
5464
- align : ['left' | 'mid' | 'right'], optional, default: 'mid'
5475
+ Default is 'bar'
5476
+
5477
+ align : {'left', 'mid', 'right'}, optional
5465
5478
Controls how the histogram is plotted.
5466
5479
5467
5480
- 'left': bars are centered on the left bin edges.
@@ -5470,34 +5483,47 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5470
5483
5471
5484
- 'right': bars are centered on the right bin edges.
5472
5485
5473
- orientation : ['horizontal' | 'vertical'], optional
5486
+ Default is 'mid'
5487
+
5488
+ orientation : {'horizontal', 'vertical'}, optional
5474
5489
If 'horizontal', `~matplotlib.pyplot.barh` will be used for
5475
5490
bar-type histograms and the *bottom* kwarg will be the left edges.
5476
5491
5477
- rwidth : scalar, optional, default: None
5492
+ rwidth : scalar or None, optional
5478
5493
The relative width of the bars as a fraction of the bin width. If
5479
- `None`, automatically compute the width. Ignored if `histtype` =
5480
- 'step' or 'stepfilled'.
5494
+ `None`, automatically compute the width.
5481
5495
5482
- log : boolean, optional, default : False
5496
+ Ignored if `histtype` is 'step' or 'stepfilled'.
5497
+
5498
+ Default is ``None``
5499
+
5500
+ log : boolean, optional
5483
5501
If `True`, the histogram axis will be set to a log scale. If `log`
5484
5502
is `True` and `x` is a 1D array, empty bins will be filtered out
5485
5503
and only the non-empty (`n`, `bins`, `patches`) will be returned.
5486
5504
5487
- color : color or array_like of colors, optional, default: None
5505
+ Default is ``False``
5506
+
5507
+ color : color or array_like of colors or None, optional
5488
5508
Color spec or sequence of color specs, one per dataset. Default
5489
5509
(`None`) uses the standard line color sequence.
5490
5510
5491
- label : string, optional, default: ''
5511
+ Default is ``None``
5512
+
5513
+ label : string or None, optional
5492
5514
String, or sequence of strings to match multiple datasets. Bar
5493
5515
charts yield multiple patches per dataset, but only the first gets
5494
5516
the label, so that the legend command will work as expected.
5495
5517
5496
- stacked : boolean, optional, default : False
5518
+ default is ``None``
5519
+
5520
+ stacked : boolean, optional
5497
5521
If `True`, multiple data are stacked on top of each other If
5498
5522
`False` multiple data are aranged side by side if histtype is
5499
5523
'bar' or on top of each other if histtype is 'step'
5500
5524
5525
+ Default is ``False``
5526
+
5501
5527
Returns
5502
5528
-------
5503
5529
n : array or list of arrays
@@ -5853,16 +5879,10 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
5853
5879
labels = [None ]
5854
5880
elif is_string_like (label ):
5855
5881
labels = [label ]
5856
- elif is_sequence_of_strings (label ):
5857
- labels = list (label )
5858
5882
else :
5859
- raise ValueError (
5860
- 'invalid label: must be string or sequence of strings' )
5861
-
5862
- if len (labels ) < nx :
5863
- labels += [None ] * (nx - len (labels ))
5883
+ labels = [str (lab ) for lab in label ]
5864
5884
5865
- for (patch , lbl ) in zip (patches , labels ):
5885
+ for (patch , lbl ) in zip_longest (patches , labels , fillvalue = None ):
5866
5886
if patch :
5867
5887
p = patch [0 ]
5868
5888
p .update (kwargs )
0 commit comments