From: <mme...@us...> - 2008-05-07 10:41:46
|
Revision: 5126 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5126&view=rev Author: mmetz_bn Date: 2008-05-07 03:41:42 -0700 (Wed, 07 May 2008) Log Message: ----------- Switched to future numpy histogram semantic in hist Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008-05-07 02:12:31 UTC (rev 5125) +++ trunk/matplotlib/API_CHANGES 2008-05-07 10:41:42 UTC (rev 5126) @@ -1,3 +1,9 @@ + In numpy 1.0 bins are specified by the left edges only. The axes + method "hist" now uses future numpy 1.3 semantic for histograms. + Providing binedges, the last value gives the upper-right edge now, + which was implicitly set to +infinity in numpy 1.0. This also means + that the last bin doesn't contain upper outliers any more by default. + New axes method and pyplot function, hexbin, is an alternative to scatter for large datasets. It makes something like a pcolor of a 2-D histogram, but uses hexagonal bins. Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008-05-07 02:12:31 UTC (rev 5125) +++ trunk/matplotlib/CHANGELOG 2008-05-07 10:41:42 UTC (rev 5126) @@ -1,3 +1,5 @@ +2008-05-07 Switched to future numpy histogram semantic in hist - MM + 2008-05-06 Fix strange colors when blitting in QtAgg and Qt4Agg - MGD 2008-05-05 pass notify_axes_change to the figure's add_axobserver Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-05-07 02:12:31 UTC (rev 5125) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-05-07 10:41:42 UTC (rev 5126) @@ -5406,11 +5406,11 @@ #### Data analysis - def hist(self, x, bins=10, normed=0, bottom=None, histtype='bar', + def hist(self, x, bins=10, normed=False, bottom=None, histtype='bar', align='edge', orientation='vertical', width=None, log=False, **kwargs): """ - HIST(x, bins=10, normed=0, bottom=None, histtype='bar', + HIST(x, bins=10, normed=False, bottom=None, histtype='bar', align='edge', orientation='vertical', width=None, log=False, **kwargs) @@ -5449,40 +5449,35 @@ %(Rectangle)s """ if not self._hold: self.cla() - n, bins = np.histogram(x, bins, range=None, normed=normed) - if width is None: - if histtype == 'bar': - width = 0.9*(bins[1]-bins[0]) - elif histtype == 'step': - width = bins[1]-bins[0] - else: - raise ValueError, 'invalid histtype: %s' % histtype + n, bins = np.histogram(x, bins, range=None, + normed=bool(normed), new=True) if histtype == 'bar': + if width is None: + width = 0.9*(bins[1]-bins[0]) + if orientation == 'horizontal': - patches = self.barh(bins, n, height=width, left=bottom, + patches = self.barh(bins[:-1], n, height=width, left=bottom, align=align, log=log) elif orientation == 'vertical': - patches = self.bar(bins, n, width=width, bottom=bottom, + patches = self.bar(bins[:-1], n, width=width, bottom=bottom, align=align, log=log) else: raise ValueError, 'invalid orientation: %s' % orientation elif histtype == 'step': - binedges = np.concatenate((bins,bins[-1:]+width)) + x = np.zeros( 2*len(bins), np.float_ ) + y = np.zeros( 2*len(bins), np.float_ ) + + x[0::2], x[1::2] = bins, bins + y[1:-1:2], y[2::2] = n, n + if align == 'center': - binedges -= 0.5*width - x = np.zeros( 2*len(binedges), np.float_ ) - y = np.zeros( 2*len(binedges), np.float_ ) + x -= 0.5*(bins[1]-bins[0]) - x[0:-1:2],x[1::2] = binedges, binedges - y[1:-1:2],y[2::2] = n, n - if orientation == 'horizontal': x,y = y,x - elif orientation == 'vertical': - pass - else: + elif orientation != 'vertical': raise ValueError, 'invalid orientation: %s' % orientation patches = self.fill(x,y) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |