@@ -6157,7 +6157,7 @@ def hist(self, x, bins=10, range=None, normed=False, cumulative=False,
61576157 - 'step' generates a lineplot that is by default
61586158 unfilled
61596159
6160- - 'stepfilled' generates a lineplot that this by default
6160+ - 'stepfilled' generates a lineplot that is by default
61616161 filled.
61626162
61636163 *align*: ['left' | 'mid' | 'right' ]
@@ -6209,26 +6209,27 @@ def hist(self, x, bins=10, range=None, normed=False, cumulative=False,
62096209 raise DeprecationWarning (
62106210 'hist now uses the rwidth to give relative width and not absolute width' )
62116211
6212- # todo: make hist() work with list of arrays with different lengths
6213- x = np .asarray (x ).copy ()
6214- if len (x .shape )== 2 and min (x .shape )== 1 :
6215- x .shape = max (x .shape ),
6216-
6217- if len (x .shape )== 2 and x .shape [0 ]< x .shape [1 ]:
6218- warnings .warn ('2D hist should be nsamples x nvariables; this looks transposed' )
6219-
6220- if len (x .shape )== 2 :
6221- n = []
6222- for i in xrange (x .shape [1 ]):
6223- # this will automatically overwrite bins,
6224- # so that each histogram uses the same bins
6225- m , bins = np .histogram (x [:,i ], bins , range = range ,
6226- normed = bool (normed ), new = True )
6227- n .append (m )
6228- else :
6229- n , bins = np .histogram (x , bins , range = range ,
6212+ try :
6213+ x = np .transpose (np .asarray (x ).copy ())
6214+ if len (x .shape )== 1 :
6215+ x .shape = (1 ,x .shape [0 ])
6216+ elif len (x .shape )== 2 and x .shape [1 ]< x .shape [0 ]:
6217+ warnings .warn ('2D hist should be nsamples x nvariables; this looks transposed' )
6218+ except ValueError :
6219+ # multiple hist with data of different length
6220+ if iterable (x [0 ]) and not is_string_like (x [0 ]):
6221+ tx = []
6222+ for i in xrange (len (x )):
6223+ tx .append ( np .asarray (x [i ]).copy () )
6224+ x = tx
6225+
6226+ n = []
6227+ for i in xrange (len (x )):
6228+ # this will automatically overwrite bins,
6229+ # so that each histogram uses the same bins
6230+ m , bins = np .histogram (x [i ], bins , range = range ,
62306231 normed = bool (normed ), new = True )
6231- n = [ n ,]
6232+ n . append ( m )
62326233
62336234 if cumulative :
62346235 slc = slice (None )
0 commit comments