-2

I have used two input arrays with an output array that I have interpolated with numpy's LinearNDInterpolator and scipy's ndimage filters. I was able to easily visualize the output using a matplotlib's pcolormesh. I would like to extend this analysis to 3 input arrays using the same ndimage and interpolation functions, but am not sure how to visualize the data. My best guess as to a solution would be to scatter the data using a solution similar to How to make a 4d plot with matplotlib using arbitrary data but more steps are needed as my output is a grid.

Here is the skeleton:

from scipy.interpolate import LinearNDInterpolator

dat_A = np.sin(np.arange(200))
dat_B = np.cos(np.arange(200))
dat_C = np.sinh(np.arange(200)/200)
output = dat_A + dat_B - 2*dat_C

A,B,C = np.arange(200),np.arange(200),np.linspace(0,2,200)

A_grid,B_grid,C_grid = np.meshgrid(A,B,C)

interp = LinearNDInterpolator(list(zip(dat_A,dat_B,dat_C)),output)

4D_out = interp(A_grid,B_grid,C_grid)

How do I visualize this 4D object? I was thinking animating through a 3D plot.

Joe Natal
  • 59
  • 8
  • Please read https://stackoverflow.com/help/how-to-ask before. Could you provide some more info about what you already have, and what you want. Some more concrete data to work with... Type of data you are trying to visualize... etc... its very difficult to suggest a method without knowing something about the data to be plotted. – mandulaj Jan 03 '21 at 07:50

1 Answers1

0

I have found an easy way to do this exact visualization task is to use animatplot, which has its own animated pcolormesh function. https://pypi.org/project/animatplot/

Joe Natal
  • 59
  • 8