Hello, I am trying to generate a 2D histogram for two arrays of data in CSV format.
The code is: x, y = '5k_vec.csv','tcd_5k.csv' H, xedges, yedges = np.histogram2d(x, y) H.shape, xedges.shape, yedges.shape # We can now use the Matplotlib to visualize this 2-dimensional histogram: extent = [yedges[0], yedges[-1], xedges[-1], xedges[0]] import matplotlib.pyplot as plt plt.imshow(H, extent=extent, interpolation='nearest') # <matplotlib.image.AxesImage object at ...> plt.colorbar() # <matplotlib.colorbar.Colorbar instance at ...> plt.show() And the errors I am getting on Wakari are: TypeError Traceback (most recent call last)<ipython-input-3-d8604c85925d> in <module>() 1 x, y = '5k_vec.csv','tcd_5k.csv'----> 2 H, xedges, yedges = np.histogram2d(x, y) 3 H.shape, xedges.shape, yedges.shape 4 5 # We can now use the Matplotlib to visualize this 2-dimensional histogram: /opt/anaconda/envs/np17py27-1.5/lib/python2.7/site-packages/numpy/lib/twodim_base.pyc in histogram2d(x, y, bins, range, normed, weights) 609 xedges = yedges = asarray(bins, float) 610 bins = [xedges, yedges]--> 611 hist, edges = histogramdd([x,y], bins, range, normed, weights) 612 return hist, edges[0], edges[1] 613 /opt/anaconda/envs/np17py27-1.5/lib/python2.7/site-packages/numpy/lib/function_base.pyc in histogramdd(sample, bins, range, normed, weights) 307 smax = ones(D) 308 else:--> 309 smin = atleast_1d(array(sample.min(0), float)) 310 smax = atleast_1d(array(sample.max(0), float)) 311 else: /opt/anaconda/envs/np17py27-1.5/lib/python2.7/site-packages/numpy/core/_methods.pyc in _amin(a, axis, out, keepdims) 12 def _amin(a, axis=None, out=None, keepdims=False): 13 return um.minimum.reduce(a, axis=axis,---> 14 out=out, keepdims=keepdims) 15 16 def _sum(a, axis=None, dtype=None, out=None, keepdims=False): TypeError: cannot perform reduce with flexible type Any help would be appreciated! -- *Rocko Brown*, MS, EIT PhD Candidate Department of Land, Air, & Water Resources University of California, Davis
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor