Skip to content

Commit 214976f

Browse files
committed
fixed a hist bug with 1xN inputs
svn path=/trunk/matplotlib/; revision=5248
1 parent db8f8c7 commit 214976f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

examples/pylab/mri_with_eeg.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
im = take(im, nonzero(im)) # ignore the background
2828
im = im/(2.0**15) # normalize
2929
hist(im, 100)
30+
print im.shape
3031
xticks([-1, -.5, 0, .5, 1])
3132
yticks([])
3233
xlabel('intensity')
@@ -84,6 +85,7 @@
8485

8586
xlabel('time (s)')
8687

88+
if 1:
89+
savefig('mri_with_eeg')
8790

88-
#savefig('mri_with_eeg')
8991
show()

lib/matplotlib/axes.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5484,8 +5484,15 @@ def hist(self, x, bins=10, normed=False, cumulative=False,
54845484
'hist now uses the rwidth to give relative width and not absolute width')
54855485

54865486
# todo: make hist() work with list of arrays with different lengths
5487-
x = np.asarray(x)
5487+
x = np.asarray(x).copy()
5488+
if len(x.shape)==2 and min(x.shape)==1:
5489+
x.shape = max(x.shape),
5490+
5491+
if len(x.shape)==2 and x.shape[0]<x.shape[1]:
5492+
warnings.warn('2D hist should be nsamples x nvariables; this looks transposed')
5493+
54885494
if len(x.shape)==2:
5495+
54895496
n = []
54905497
for i in xrange(x.shape[1]):
54915498
# this will automatically overwrite bins,

0 commit comments

Comments
 (0)