Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The following works for me:

import numpy
import scipy.interpolate 

n = 10
numbers = numpy.random.random_sample( ( n**3, ) )
data    = numpy.reshape( numbers, (n,n,n) )
xi = yi = zi = np.linspace(1, n, n)
interp = scipy.interpolate.RegularGridInterpolator((xi,yi,zi), data)
var('x,y,z')
test = implicit_plot3d( lambda x,y,z: interp( (x,y,z) )
                        , (x,1,n)
                        , (y,1,n)
                        , (z,1,n)
                        , plot_points=60, color='seagreen', contour=0.5) 
test.show()

My favorite values for n were in the tests $3$ or $5$, to make the machine less angry. And for the numbers, it was numbers = [ 1 for _ in range(n**3) ] .

The difference is the use of lambda x,y,z: interp( (x,y,z) ) instead of interp.