Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1952d93

Browse filesBrowse files
committed
Switched to future numpy histogram semantic in hist
svn path=/trunk/matplotlib/; revision=5126
1 parent 9bd1746 commit 1952d93
Copy full SHA for 1952d93

File tree

Expand file treeCollapse file tree

3 files changed

+25
-22
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+25
-22
lines changed

‎API_CHANGES

Copy file name to clipboardExpand all lines: API_CHANGES
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
In numpy 1.0 bins are specified by the left edges only. The axes
2+
method "hist" now uses future numpy 1.3 semantic for histograms.
3+
Providing binedges, the last value gives the upper-right edge now,
4+
which was implicitly set to +infinity in numpy 1.0. This also means
5+
that the last bin doesn't contain upper outliers any more by default.
6+
17
New axes method and pyplot function, hexbin, is an alternative
28
to scatter for large datasets. It makes something like a
39
pcolor of a 2-D histogram, but uses hexagonal bins.

‎CHANGELOG

Copy file name to clipboardExpand all lines: CHANGELOG
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2008-05-07 Switched to future numpy histogram semantic in hist - MM
2+
13
2008-05-06 Fix strange colors when blitting in QtAgg and Qt4Agg - MGD
24

35
2008-05-05 pass notify_axes_change to the figure's add_axobserver

‎lib/matplotlib/axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes.py
+17-22Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5406,11 +5406,11 @@ def twiny(self):
54065406
#### Data analysis
54075407

54085408

5409-
def hist(self, x, bins=10, normed=0, bottom=None, histtype='bar',
5409+
def hist(self, x, bins=10, normed=False, bottom=None, histtype='bar',
54105410
align='edge', orientation='vertical', width=None,
54115411
log=False, **kwargs):
54125412
"""
5413-
HIST(x, bins=10, normed=0, bottom=None, histtype='bar',
5413+
HIST(x, bins=10, normed=False, bottom=None, histtype='bar',
54145414
align='edge', orientation='vertical', width=None,
54155415
log=False, **kwargs)
54165416
@@ -5449,40 +5449,35 @@ def hist(self, x, bins=10, normed=0, bottom=None, histtype='bar',
54495449
%(Rectangle)s
54505450
"""
54515451
if not self._hold: self.cla()
5452-
n, bins = np.histogram(x, bins, range=None, normed=normed)
5453-
if width is None:
5454-
if histtype == 'bar':
5455-
width = 0.9*(bins[1]-bins[0])
5456-
elif histtype == 'step':
5457-
width = bins[1]-bins[0]
5458-
else:
5459-
raise ValueError, 'invalid histtype: %s' % histtype
5452+
n, bins = np.histogram(x, bins, range=None,
5453+
normed=bool(normed), new=True)
54605454

54615455
if histtype == 'bar':
5456+
if width is None:
5457+
width = 0.9*(bins[1]-bins[0])
5458+
54625459
if orientation == 'horizontal':
5463-
patches = self.barh(bins, n, height=width, left=bottom,
5460+
patches = self.barh(bins[:-1], n, height=width, left=bottom,
54645461
align=align, log=log)
54655462
elif orientation == 'vertical':
5466-
patches = self.bar(bins, n, width=width, bottom=bottom,
5463+
patches = self.bar(bins[:-1], n, width=width, bottom=bottom,
54675464
align=align, log=log)
54685465
else:
54695466
raise ValueError, 'invalid orientation: %s' % orientation
54705467

54715468
elif histtype == 'step':
5472-
binedges = np.concatenate((bins,bins[-1:]+width))
5469+
x = np.zeros( 2*len(bins), np.float_ )
5470+
y = np.zeros( 2*len(bins), np.float_ )
5471+
5472+
x[0::2], x[1::2] = bins, bins
5473+
y[1:-1:2], y[2::2] = n, n
5474+
54735475
if align == 'center':
5474-
binedges -= 0.5*width
5475-
x = np.zeros( 2*len(binedges), np.float_ )
5476-
y = np.zeros( 2*len(binedges), np.float_ )
5476+
x -= 0.5*(bins[1]-bins[0])
54775477

5478-
x[0:-1:2],x[1::2] = binedges, binedges
5479-
y[1:-1:2],y[2::2] = n, n
5480-
54815478
if orientation == 'horizontal':
54825479
x,y = y,x
5483-
elif orientation == 'vertical':
5484-
pass
5485-
else:
5480+
elif orientation != 'vertical':
54865481
raise ValueError, 'invalid orientation: %s' % orientation
54875482
patches = self.fill(x,y)
54885483
else:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.