Hi all,
I have been using contourf quite happily with a square number of grid points. e.g. a 20 by 20 grid. I recently decided to do a contourf plot of a 20 by 15 grid (300 points) and I get errors. Unfortunately, I am plotting experimental data so I cannot really tailor the grid size. Here is the error message ipython generates:
pylab.contourf((map_XX,map_YY,y))
···
TypeError Traceback (most recent call last)
/media/ANAMIKA/crashing out Raman/script_7-03-10_co1_G-mode_spatial_map.py in ()
----> 1
2
3
4
5
/usr/lib/pymodules/python2.6/matplotlib/pyplot.pyc in contourf(*args, **kwargs)
1874 ax.hold(hold)
1875 try:
-> 1876 ret = ax.contourf(*args, **kwargs)
1877 draw_if_interactive()
1878 finally:
/usr/lib/pymodules/python2.6/matplotlib/axes.pyc in contourf(self, *args, **kwargs)
6816 if not self._hold: self.cla()
6817 kwargs[‘filled’] = True
-> 6818 return mcontour.ContourSet(self, *args, **kwargs)
6819 contourf.doc = mcontour.ContourSet.contour_doc
6820
/usr/lib/pymodules/python2.6/matplotlib/contour.pyc in init(self, ax, *args, **kwargs)
572 raise ValueError(‘Either colors or cmap must be None’)
573 if self.origin == ‘image’: self.origin = mpl.rcParams[‘image.origin’]
–> 574 x, y, z = self._contour_args(*args) # also sets self.levels,
575 # self.layers
576 if self.colors is not None:
/usr/lib/pymodules/python2.6/matplotlib/contour.pyc in _contour_args(self, *args)
759 if Nargs <= 2:
760 z = ma.asarray(args[0], dtype=np.float64)
–> 761 x, y = self._initialize_x_y(z)
762 elif Nargs <=4:
763 x,y,z = self._check_xyz(args[:3])
/usr/lib/pymodules/python2.6/matplotlib/contour.pyc in _initialize_x_y(self, z)
696 ‘’’
697 if z.ndim != 2:
–> 698 raise TypeError(“Input must be a 2D array.”)
699 else:
700 Ny, Nx = z.shape
TypeError: Input must be a 2D array.
If anyone has a solution, please do let me know!
Many thanks!