Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73449

Problem with numpy 2D Histogram

Newsgroups comp.lang.python
Date 2014-06-20 01:46 -0700
Message-ID <f6254d0b-4803-47c8-8b58-aadc9d762610@googlegroups.com> (permalink)
Subject Problem with numpy 2D Histogram
From Jamie Mitchell <jamiemitchell1604@gmail.com>

Show all headers | View raw


Hi folks,

I'm trying to plot a 2D histogram but I'm having some issues:
from pylab import *
import numpy as np
import netCDF4
hist,xedges,yedges=np.histogram2d(x,y,bins=10)
extent=[xedges[0],xedges[-1],yedges[0],yedges[-1]]
imshow(hist.T,extent=extent,interpolation='nearest')
colorbar()
show()

After the first line of code I get:
TypeError: Cannot cast array data from dtype('O') to dtype('float64') according to the rule 'safe'

I'm using python2.7, x and y are type 'numpy.ndarray'

Cheers,
Jamie

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 01:46 -0700
  Re: Problem with numpy 2D Histogram Peter Otten <__peter__@web.de> - 2014-06-20 11:25 +0200
    Re: Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 02:57 -0700
      Re: Problem with numpy 2D Histogram Peter Otten <__peter__@web.de> - 2014-06-20 13:00 +0200
        Re: Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 04:58 -0700
          Re: Problem with numpy 2D Histogram Peter Otten <__peter__@web.de> - 2014-06-20 14:30 +0200
  Re: Problem with numpy 2D Histogram Jamie Mitchell <jamiemitchell1604@gmail.com> - 2014-06-20 06:54 -0700

csiph-web