ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 05 Sep 2017 04:31:34 -0500Empty graph using implicit_plot3d with contour-optionhttp://ask.sagemath.org/question/38741/empty-graph-using-implicit_plot3d-with-contour-option/Hello everybody,
I wanted to make an isosurface plot from a 3d matrix, which contains random values from 0 to 1 at an equally spaced 3d grid.
Therefore I generated random numbers, and reshaped them in a 3d matrix. I interpolated the 3d matrix linearly with the RegularGridInterpolator from scipy. To make a 3D plot of it I am using the implicit_plot3d function of sage with a given contour value.
I get no errors, but in the end the graph is empty, which should not be in my opinion.
Here is my code:
from scipy.interpolate import griddata
import numpy as np
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm
import scipy.interpolate
numbers=np.random.random_sample((1000,)) #generate random numbers
#print numbers
data = np.reshape(numbers, (10, 10, 10)) #reshape the numbers on a 3D matrix
#print data
xi = yi = zi = np.linspace(1, 10, 10)
interp = scipy.interpolate.RegularGridInterpolator((xi,yi,zi), data) #interpolate the 3d matrix with a function
#print xi
var('x,y,z')
#test = implicit_plot3d(interp,(x,1,10),(y,1,10),(z,1,10),contour=0.5)
test = implicit_plot3d(interp==0.5,(x,1,10), (y,1,10),(z,1,10),plot_points=60, color='seagreen')
test.show() #plot the the function at a certain value
#a=(5.,5.,2.)
#interp(a)
Any ideas on that?
Thank you very much!osTue, 05 Sep 2017 04:31:34 -0500http://ask.sagemath.org/question/38741/