This question is related to this
I want to plot the following 4 column data
X Y Z V(X,Y,Z)
1 1 1 1.1
1 1 2 1.0
1 1 3 1.0
1 2 1 0.9
1 2 2 1
1 2 3 1.8
1 3 1 0.9
1 3 2 1
1 3 3 1.1
2 1 1 1.1
2 1 2 1.0
2 1 3 1.0
2 2 1 0.5
2 2 2 1.7
2 2 3 1.2
2 3 1 0.9
2 3 2 1
2 3 3 1.1
3 1 1 1.3
3 1 2 1.0
3 1 3 1.2
3 2 1 0.9
3 2 2 1
3 2 3 1.1
3 3 1 0.8
3 3 2 1.2
3 3 3 1.4
So, basically I want to plot a figure with 3 axes and the values of the function with colors. For, plotting {X,Y,Z(X,Y)}
there are plenty of examples,for instance. Being not a programmer, I have tired to extend this example to create a meshgrid(X,Y,Z).(I am not sure whether this even make any sense or not!) with no sucess. Most of the question related to 4D plot in python is either unanswered or not suitable for my requirement. Please help.
N.B. This is what I would like to generate(generated in Mathematica)
And this is what I have tried to do in python(!)
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
from scipy.interpolate import griddata
data = np.loadtxt('mydata.dat')
X = data[:,0]
Y = data[:,1]
Z = data[:,2]
val= data[:3]
xi = np.linspace(X.min(), X.max(), 3)
yi = np.linspace(Y.min(), Y.max(), 3)
zi = np.linspace(Y.min(), Y.max(), 3)
vali = griddata((X,Y,Z), val, (xi[None,:], yi[:,None], zi[:,None]))
fig = plt.figure(figsize=plt.figaspect(0.5))
ax = Axes3D(fig)
xig, yig, zig = np.meshgrid(xi, yi, zi)
surf = ax.plot_surface(xig, yig, zig, vali,cmap=cm.jet, linewidth=0,
antialiased=False, shade=True,alpha=1.0)