Issue
I have just started to learn python and I encounter a problem while trying to produce a figure.
I have a large set of points (~ 42000) with X-Y-Z coordinates and with several variable associated (temperature, water content ...) I would like to plot all this stuff in one graph but it appears to be impossible with my level of python knowledge.. All these points are situated on a cartesian regular grid. So I wanted to produce a meshgrid grid with numpy but the I'm stuck .. Basically I want to transfrom 1D vector (X,Y,Z and T let's say) into a 3d grid with interpolated data. Is that possible ?
Could you please help me ?
Solution
I don't understand so well what you want. But if you intend to do a 4D plot you will need a fourth dimension (do you have an example of what you want?). I used the color as another dimension, in this example I plotted a Gaussian over R^3 centered at (0,0,0) and the color of each point gives the value of the function.
import numpy as np
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
X, Y, Z = np.mgrid[-1:1:10j, -1:1:10j, -1:1:10j]
T = np.exp(-X**2 - Y**2 - Z**2)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
scat = ax.scatter(X, Y, Z, c=Z.flatten(), alpha=0.5)
fig.colorbar(scat, shrink=0.5, aspect=5)
You can use the scipy.interpolate for the interpolation part.
Answered By - nicoguaro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.