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 ?
This is complicated data to view, so I think you'll need a tool designed to make viewing of 3D data easy, and MayaVi is an excellent option for this.
Here's an example,
And the most important aspect of this is that it's highly interactive, so using the mouse I can easily grab and move around the slice planes. and even tilt them to explore the data volumetric data (which is very useful, as in this case we can see it's mostly red on the inside, which we couldn't have guessed from just the surface):
Here's the code, which is just a slightly modified version of this:
from mayavi import mlab
import numpy as np
x, y, z = np.ogrid[-2:2:20j, -2:2:20j, -2:2:20j]
s = np.sin(x*y*z + x + y*z)/(x*y*z + x + y*z)
mlab.pipeline.image_plane_widget(mlab.pipeline.scalar_field(s),
plane_orientation='x_axes',
slice_index=20,
)
mlab.pipeline.image_plane_widget(mlab.pipeline.scalar_field(s),
plane_orientation='y_axes',
slice_index=20,
)
mlab.pipeline.image_plane_widget(mlab.pipeline.scalar_field(s),
plane_orientation='z_axes',
slice_index=20,
)
mlab.outline()
mlab.show()
Check matplotlib, it is a nice and well-illustrated python plotting module, you should find what you need !
A first example
Specific 3D example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With