note: problem with <type 'array'> in pcolor

[The following problem seems to occur with Numeric but not with numarray]

The following code


from matplotlib.matlab import *

x = arange(0,20,.2)
y = arange(0,20,.2)
X, Y = meshgrid(x,y)
for i in enumerate(x):
    for j in enumerate(y):
       #or z[i[0],j[0]]=10*sin(i[1]*j[1])
pcolor(X,Y, transpose(z),shading='faceted')

breaks in the module

   def get_color(self, val, valmin, valmax):
       # map val to a range
from 0 to 1
       if iterable(val):
          s = "val must be a scalar.
Perhaps you meant to call get_colors?"
          #print val,type(val)
          raise ValueError, s
       #print valmin, valmax
       ind = self.indmax*(val-valmin)/(valmax-valmin)

because the test for iterable fails since the element C[i,j] is type
<array>. One solution is to change the code section around line 1126 in from c = C[i,j] to the following.

        for i in range(Nx-1):
            for j in range(Ny-1):

    c = C[i][j]

the form C[i][j] seems to always return float.