3D mapping of focused ultrasound signal - python

I have a 3D stage which carries a sensor and measures Ultrasonic signals in 3D space at specified points. What would be the best way of visualizing this data in python?

Your question can be interpreted in two ways:
1) What is a good python tool for drawing such a visualization?
2) What is a good visualization for such data?
I'll tackle both:
1) matplotlib looks sufficient.
2) I think a a 3D scatter plot is a good visualization for such data. This is because you can capture 4 dimensions of data: x,y,z and colour. Also, x,y,z closely resemble space. If it's possible to change the plots' sizes, then you have a 5th dimension.

Related

How to set camera angle of a 2D plot in matplotlib?

I have generated a series of 2D plots using matplotlib.pyplot. I want to change the perspective of each 2D plot to make them look more "3D" (from the rectangular shape to parallelogram shape) and stack them together by hand, which will look something like this:
If there are texts present in the 2D plot (e.g. labels, title, legend), I want them to be rotated together with the plot. The reason I don't want to use mplot3d is that it doesn't support some advanced functions that is used in my 2D plots.
This has already been asked before for 3D plots: how to set "camera position" for 3d plots using python/matplotlib?, but the ax.view_init is only implemented for 3D plots. I wonder if there is a way to also change the camera angle for a 2D plot. If not, are there any tools that can do this task?

Slicing a multidimensional numpy array -> 3D point clusters at different time instances

I have a numpy-array, who's shape is:
(30,40,100,200)
Those are 3D points (30(x-axis)x40(y-axis)x100(z-axis)) for different times (200 in total):
For visualization only (this is not my dataset, the picture comes from here: http://15462.courses.cs.cmu.edu/fall2016/article/35)
Now, I have issues with understanding how I can slice it:
How do I extract a 3D cluster for one specific time, i.e. 140?
From that extracted 3D cluster, how can I plot a 2D x-z cross-section for a specific y-position, i.e.45?
You should read up on basic numpy slicing: https://numpy.org/doc/stable/reference/arrays.indexing.html
How do I extract a 3D cluster for one specific time, i.e. 140?
Just specify the time index, i.e. data[:, :, :, 140]. Be aware that Python indexing starts from 0.
From that extracted 3D cluster, how can I plot a 2D x-z cross-section for a specific y-position, i.e.45?
You can acquire a 2D cross-section by a similar slicing operation, i.e. cluster[:, 45, :]. It can be plotted in various ways depending on the plotting library. imshow() from matplotlib might be one possibility.
Is your question about the data set (how does data categorize and how to get a 3D cluster at a specific time), or about the coding?
If it is about "How to get a cluster at a specific time" it means that your problem is about your particular dataset, which Stackoverflow is not a correct place for these types of question.
If it is about "coding" then define clearly your question and provide us with your code and the problem with it.
Based on your explanation, I think that for each time step, you have a complete set of xyz data, and so the solution is very strait.

3D plot of 2D pandas data frame - z-axis limits, interactivity

I Posted this question about 3D plots of data frames:
3D plot of 2d Pandas data frame
and the user referred me very very helfully to this:
Plotting Pandas Crosstab Dataframe into 3D bar chart
It use useful and the code worked in principle, but it lookes like a mess (see image below) for several reasons:
I have huge number of values to plot (470 or so, along the y-axis) so perhaps a bar chart is not the best way (I am going for a histogram kind of look, so I assumed very narrow bars would be suitable)
my counts (z axis) do not give almost any information, because the differences I need to see are from 100 to the max value
how can I make the 3D plot that shows up interactive? (being able to rotate etc) - I have seen it done in blogs/videos but sure if it's something on Tools -> Preferences that I can't find
So re: the second issue, simple enough, I tried to just change the limits of the zbar as I would for a 2D Plot, by incorporating:
ax.set_zlim([110,150])
just before the axis labels, but obviously this is the wrong way:
SO do I have to limit the values from the original data set (i.e. filter out <110), or is there a way to do this from the plot?

How to make a contour plot with three variables in a dataset?

I am trying to generate a contour graph in terms of three parameters (say x, y, z). These parameters come from a data table of more than 5000 values.I need the graphics to look like the figures shown below.
Contour plots are most easily made using matplotlib's contour.
There's also a corresponding contourf function that provides filled contours. Anyway, what you uploaded looks more like matplotlib's pcolor or pcolormesh, as they draw colored pixels instead of isovalue lines.
Here's a nice comparison of both if you need to choose.
Edit: For (x,y,z) points that are not distributed on a grid (i.e. come from random samples), a working solution seems to be a combination of binned_statistic_2d and then either plt.pcolor or plt.contour.

What is the best way to create a figure with distributions as insets in python?

I created a graph in MATLAB (see figure below) such that around every data point there is a data distribution plotted (grey area plots). The way I did it in MATLAB was to create a set of axes for every distribution curve and then plot the curves without showing those axes at every point of the data curve. I also used a command 'linkaxes' to set figure limits for all the curves at once.
I must say that this is far from an elegant solution and I had many troubles with saving this figure in the correct aspect ratio settings. All in all I couldn't find any other useful option in MATLAB.
Is there a more elegant solution for such types of graphs in Python? I am not that much interested in how to do the areas highlighted, but how to place a set of curves(distributions) exactly at the positions of the main data curve points.
Thank you!

Categories

Resources