Skip to content

griddata constant spacing check needs tweaking #666

@ivanov

Description

@ivanov

as reported by Ethan Swint to the mpl-users mailing list:

I was working off of the example listed at
http://matplotlib.sourceforge.net/examples/pylab_examples/griddata_demo.html,
adapting it to my own data, and encountered the following error on MLAB
1.1.0, Python 2.7.2:

from numpy.random import uniform, seed
from matplotlib.mlab import griddata
import matplotlib.pyplot as plt
import numpy as np
# make up data.
#npts = int(raw_input('enter # of random points to plot:'))
seed(0)
npts = 200
x = uniform(-2,2,npts)
y = uniform(-2,2,npts)
z = x*np.exp(-x**2-y**2)
xi = np.linspace(0,60,100)  # <= my xdata range
yi = np.linspace(0,0.9,200) # <= my ydata range
zi = griddata(x,y,z,xi,yi,interp='linear')

which produces

------------------------------------------------------------
ValueError                                Traceback (most recent call last)
C:\Users\Ethan\code\PythonScripts\<ipython-input-7-51e10e494403> in
<module>()
----> 1 zi = griddata(x,y,z,xi,yi,interp='linear')

   matplotlib/mlab.pyc in griddata(x, y, z, xi, yi, interp)
   2778             epsy = np.finfo(yi.dtype).resolution
   2779             if dx.max()-dx.min() > epsx or dy.max()-dy.min() > epsy:
-> 2780                 raise ValueError("output grid must have constant spacing"
   2781                                  " when using interp='linear'")
   2782             interp = tri.linear_interpolator(z)

ValueError: output grid must have constant spacing when using interp='linear'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions