@@ -5878,65 +5878,60 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
5878
5878
arrays which are not required to be of the same length
5879
5879
5880
5880
bins : integer or array_like or 'auto', optional
5881
- If an integer is given, `bins + 1` bin edges are returned,
5881
+ If an integer is given, `` bins + 1` ` bin edges are returned,
5882
5882
consistently with :func:`numpy.histogram` for numpy version >=
5883
5883
1.3.
5884
5884
5885
- Unequally spaced bins are supported if ` bins` is a sequence.
5885
+ Unequally spaced bins are supported if * bins* is a sequence.
5886
5886
5887
5887
If Numpy 1.11 is installed, may also be ``'auto'``.
5888
5888
5889
5889
Default is taken from the rcParam ``hist.bins``.
5890
5890
5891
5891
range : tuple or None, optional
5892
5892
The lower and upper range of the bins. Lower and upper outliers
5893
- are ignored. If not provided, ` range` is (x.min(), x.max()). Range
5894
- has no effect if ` bins` is a sequence.
5893
+ are ignored. If not provided, * range* is `` (x.min(), x.max())``.
5894
+ Range has no effect if * bins* is a sequence.
5895
5895
5896
- If ` bins` is a sequence or ` range` is specified, autoscaling
5896
+ If * bins* is a sequence or * range* is specified, autoscaling
5897
5897
is based on the specified bin range instead of the
5898
5898
range of x.
5899
5899
5900
5900
Default is ``None``
5901
5901
5902
- normed, density : boolean, optional
5903
- Either the 'normed' or the 'density' arg can be set to
5904
- accomplish this behavior:
5905
-
5906
- If `True`, the first element of the return tuple will
5902
+ density : boolean, optional
5903
+ If ``True``, the first element of the return tuple will
5907
5904
be the counts normalized to form a probability density, i.e.,
5908
5905
the area (or integral) under the histogram will sum to 1.
5909
5906
This is achieved dividing the count by the number of observations
5910
- times the bin width and * not* dividing by the total number
5911
- of observations. If ` stacked` is also `True`, the sum of the
5907
+ times the bin width and not dividing by the total number
5908
+ of observations. If * stacked* is also `` True` `, the sum of the
5912
5909
histograms is normalized to 1.
5913
5910
5914
- Default is ``None`` for both ' normed' and ' density.' If either is
5915
- set, then that value will be used. If neither are set, then the args
5916
- will be treated as ' False.'
5911
+ Default is ``None`` for both * normed* and * density*. If either is
5912
+ set, then that value will be used. If neither are set, then the
5913
+ args will be treated as `` False``.
5917
5914
5918
- If both are set to different things, the hist function raises an
5919
- error.
5915
+ If both *density* and *normed* are set an error is raised.
5920
5916
5921
5917
weights : (n, ) array_like or None, optional
5922
- An array of weights, of the same shape as `x` . Each value in `x`
5918
+ An array of weights, of the same shape as *x* . Each value in *x*
5923
5919
only contributes its associated weight towards the bin count
5924
- (instead of 1). If ` normed` or ' density' is True,
5920
+ (instead of 1). If * normed* or * density* is `` True`` ,
5925
5921
the weights are normalized, so that the integral of the density
5926
5922
over the range remains 1.
5927
5923
5928
5924
Default is ``None``
5929
5925
5930
5926
cumulative : boolean, optional
5931
- If `True`, then a histogram is computed where each bin gives the
5927
+ If `` True` `, then a histogram is computed where each bin gives the
5932
5928
counts in that bin plus all bins for smaller values. The last bin
5933
- gives the total number of datapoints. If `normed` or 'density'
5934
- is also `True` then the histogram is normalized such that the last
5935
- bin equals 1. If `cumulative` evaluates to less than 0 (e.g., -1),
5936
- the direction of accumulation is reversed. In this case, if
5937
- `normed` and/or 'density' is also `True`, then the histogram is
5938
- normalized such that the first bin
5939
- equals 1.
5929
+ gives the total number of datapoints. If *normed* or *density*
5930
+ is also ``True`` then the histogram is normalized such that the
5931
+ last bin equals 1. If *cumulative* evaluates to less than 0
5932
+ (e.g., -1), the direction of accumulation is reversed.
5933
+ In this case, if *normed* and/or *density* is also ``True``, then
5934
+ the histogram is normalized such that the first bin equals 1.
5940
5935
5941
5936
Default is ``False``
5942
5937
@@ -5982,22 +5977,23 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
5982
5977
5983
5978
rwidth : scalar or None, optional
5984
5979
The relative width of the bars as a fraction of the bin width. If
5985
- `None`, automatically compute the width.
5980
+ `` None` `, automatically compute the width.
5986
5981
5987
- Ignored if ` histtype` is 'step' or 'stepfilled'.
5982
+ Ignored if * histtype* is 'step' or 'stepfilled'.
5988
5983
5989
5984
Default is ``None``
5990
5985
5991
5986
log : boolean, optional
5992
- If `True`, the histogram axis will be set to a log scale. If `log`
5993
- is `True` and `x` is a 1D array, empty bins will be filtered out
5994
- and only the non-empty (`n`, `bins`, `patches`) will be returned.
5987
+ If ``True``, the histogram axis will be set to a log scale. If
5988
+ *log* is ``True`` and *x* is a 1D array, empty bins will be
5989
+ filtered out and only the non-empty ``(n, bins, patches)``
5990
+ will be returned.
5995
5991
5996
5992
Default is ``False``
5997
5993
5998
5994
color : color or array_like of colors or None, optional
5999
5995
Color spec or sequence of color specs, one per dataset. Default
6000
- (`None`) uses the standard line color sequence.
5996
+ (`` None` `) uses the standard line color sequence.
6001
5997
6002
5998
Default is ``None``
6003
5999
@@ -6009,19 +6005,19 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6009
6005
default is ``None``
6010
6006
6011
6007
stacked : boolean, optional
6012
- If `True`, multiple data are stacked on top of each other If
6013
- `False` multiple data are aranged side by side if histtype is
6008
+ If `` True` `, multiple data are stacked on top of each other If
6009
+ `` False` ` multiple data are aranged side by side if histtype is
6014
6010
'bar' or on top of each other if histtype is 'step'
6015
6011
6016
6012
Default is ``False``
6017
6013
6018
6014
Returns
6019
6015
-------
6020
6016
n : array or list of arrays
6021
- The values of the histogram bins. See ** normed or density* *
6022
- and ** weights* * for a description of the possible semantics.
6023
- If input **x* * is an array, then this is an array of length
6024
- ** nbins* *. If input is a sequence arrays
6017
+ The values of the histogram bins. See *normed* or *density *
6018
+ and *weights* for a description of the possible semantics.
6019
+ If input *x * is an array, then this is an array of length
6020
+ *nbins*. If input is a sequence arrays
6025
6021
``[data1, data2,..]``, then this is a list of arrays with
6026
6022
the values of the histograms for each of the arrays in the
6027
6023
same order.
@@ -6046,59 +6042,15 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
6046
6042
Notes
6047
6043
-----
6048
6044
Until numpy release 1.5, the underlying numpy histogram function was
6049
- incorrect with `normed`=` True` if bin sizes were unequal. MPL
6050
- inherited that error. It is now corrected within MPL when using
6045
+ incorrect with ``normed= True` ` if bin sizes were unequal. MPL
6046
+ inherited that error. It is now corrected within MPL when using
6051
6047
earlier numpy versions.
6052
6048
6053
6049
"""
6054
6050
# Avoid shadowing the builtin.
6055
6051
bin_range = range
6056
6052
del range
6057
6053
6058
- # Sets the density variable, if necessary, to its predecessor, 'normed.'
6059
- if density is not None and normed is not None :
6060
- raise ValueError ('The density and normed arguments represent the '
6061
- 'same concept. Please set only one of them.' )
6062
- elif normed is not None and density is None :
6063
- density = normed
6064
- elif normed is None and density is None :
6065
- density = False
6066
-
6067
- def _normalize_input (inp , ename = 'input' ):
6068
- """Normalize 1 or 2d input into list of np.ndarray or
6069
- a single 2D np.ndarray.
6070
-
6071
- Parameters
6072
- ----------
6073
- inp : iterable
6074
- ename : str, optional
6075
- Name to use in ValueError if `inp` can not be normalized
6076
-
6077
- """
6078
- if (isinstance (x , np .ndarray ) or
6079
- not iterable (cbook .safe_first_element (inp ))):
6080
- # TODO: support masked arrays;
6081
- inp = np .asarray (inp )
6082
- if inp .ndim == 2 :
6083
- # 2-D input with columns as datasets; switch to rows
6084
- inp = inp .T
6085
- elif inp .ndim == 1 :
6086
- # new view, single row
6087
- inp = inp .reshape (1 , inp .shape [0 ])
6088
- else :
6089
- raise ValueError (
6090
- "{ename} must be 1D or 2D" .format (ename = ename ))
6091
- if inp .shape [1 ] < inp .shape [0 ]:
6092
- warnings .warn (
6093
- '2D hist input should be nsamples x nvariables;\n '
6094
- 'this looks transposed '
6095
- '(shape is %d x %d)' % inp .shape [::- 1 ])
6096
- else :
6097
- # multiple hist with data of different length
6098
- inp = [np .asarray (xi ) for xi in inp ]
6099
-
6100
- return inp
6101
-
6102
6054
if not self ._hold :
6103
6055
self .cla ()
6104
6056
@@ -6124,9 +6076,10 @@ def _normalize_input(inp, ename='input'):
6124
6076
stacked = True
6125
6077
6126
6078
if density is not None and normed is not None :
6127
- raise ValueError ("kwargs 'density' and 'normed' cannot be used"
6128
- "simultaneously. Please only use 'density', since "
6129
- "'normed' will be deprecated. " )
6079
+ raise ValueError ("kwargs 'density' and 'normed' cannot be used "
6080
+ "simultaneously. "
6081
+ "Please only use 'density', since 'normed'"
6082
+ "will be deprecated." )
6130
6083
6131
6084
# process the unit information
6132
6085
self ._process_unit_info (xdata = x , kwargs = kwargs )
0 commit comments