Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib 2D slice of 3D data

I haven't been able to find anything on this, maybe because I don't have the right nomenclature (i.e. I don't know exactly how to ask for it), but anyway, I have a 3D numpy array "a". I would like to identify and plot the 2D surface where a=0. To make clear, the data is double precision floats smoothly varying over 3D space. It is highly likely that the surface a=0 will "thread between" the points of the array, and not exactly lie right on any of them. So I need something that can interpolate to find the a=0 surface and plot it. Does matplotlib have a ready-made routine for doing this?

like image 331
bob.sacamento Avatar asked Jun 17 '16 14:06

bob.sacamento


People also ask

How do I plot a 2D frame in Matplotlib?

To select a 2D frame, pick a frame for the first axis and select all data from the remaining two: vol [0, :, :] For this exercise, use for loop to plot every 40th slice of vol on a separate subplot. matplotlib.pyplot (as plt) has been imported for you.

How can I view slices of a sample in Matplotlib?

These include magnetic resonance imaging (MRI) and serial section transmission electron microscopy (ssTEM), in which a sample is thinly sliced, like a salami, and each of the slices is imaged separately. To view such images in matplotlib, we have to choose a slice, and display only that slice.

How to plot 3D and 4D images?

The simplest way to plot 3D and 4D images by slicing them into many 2D frames. Plotting many slices sequentially can create a "fly-through" effect that helps you understand the image as a whole.

How do you plot a subplot in Matplotlib?

Using plt.subplots (), initialize a subplots grid with 1 row and 4 columns. Plot every 40th slice of vol in grayscale. To get the appropriate index, multiply ii by 40. Turn off the ticks, labels, and frame for each subplot.


1 Answers

With Plotly you can plot both planar and nonlinear slices in volumetric data: http://nbviewer.jupyter.org/github/empet/Plotly-plots/blob/master/Plotly-Slice-in-volumetric-data.ipynb

like image 53
xecafe Avatar answered Oct 22 '22 04:10

xecafe