Shrividya Ravi wrote: > 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))
It looks like the problem is that you have an extra set of parentheses, so that you are giving contourf a single argument--a tuple--instead of the three arguments that you intend. Contour and contourf have no problem with rectangular grids. Eric > * > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > > /media/ANAMIKA/crashing out > Raman/script_7-03-10_co1_G-mode_spatial_map.py in <module>() > ----> 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! > > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > > > ------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users