MATLAB Answers


how to plot a multiple 4d array on same graph

Asked by priya nair on 10 Jul 2019
Latest activity Commented on by priya nair on 11 Jul 2019
I want to plot multiple 3d graphs in a single graph.
I have my data in the form x1, x2, y and z= fun(x1,x2,y). In similar manner i have four set of values which are to be plotted in the same graph.
I tried using isosurface command but it didnt work well.
So please help me in plotting the graph
Thanks in advance


on 10 Jul 2019
Attach your data and show us your expectations.
The following is my data and i need to show all these four plots in a single graph
clear all
syms x1 x2 y
[x1,x2,y] = ndgrid(linspace(-pi,0,120),linspace(0,pi/2,120),linspace(-pi,0,120));
+((3+sqrt(2))/2)*x1.^2+ ((16+2*sqrt(2))/3)*x1.*x2+((1-sqrt(2))/6)*x2.^2....
hold on
[x1,x2,y] = ndgrid(linspace(-pi,0,120),linspace(0,pi/2,120),linspace(-pi,0,120));
hold on
[x1,x2,y] = ndgrid(linspace(-pi,0,120),linspace(0,pi/2,120),linspace(-pi,0,120));
+((3+sqrt(2))/2)*x1.^2+ ((16+2*sqrt(2))/3)*x1.*x2;
[x1,x2,y] = ndgrid(linspace(-pi,0,120),linspace(0,pi/2,120),linspace(-pi,0,120));
f= 2*(x1+x2)+y+x1.*y+(4/3)*x1.*x2.*y...
+((10+sqrt(2))/6)*x1.^2+ 4*x1.*x2+x2.^2+2*x1.*y....
hold off

Sign in to comment.



1 Answer

Answer by Bjorn Gustavsson on 10 Jul 2019
 Accepted Answer

It is still a bit unclear exactly what type of data you have, but multiple 4-D data in one graph is a lot of information to digest for any viewer, it might be the right thing to do and regardless you might still want to do it.
If you have reasonable sparse data, or only a few points (per dimension) you might get a good overview-plot using scatter3:
But that will only let you present 2 of the data-sets. If you have data that you can somewhat interpret as a vector-field there are some file exchange contributions for enhanced quiver-plots (if you can use 3 data-sets for the vector-components and the fourth for colour): quiver3_c, Quiver. There are other tools for tensor-field visualization: Tensor-field-visualization that might be of use.
If you have 4 sets of volumetric data on a "dense" regular grid, then my suggestion is that you should reconsider your design - even scalar volumetric visualization is dodgy - nice-looking for overview data visualization but quantitatively dodgy for our 2-eye-visual perception. You might find some extensions of slice: slice-variant at FEX. Though I'd be inclined to extend tcolor to plot i 3-D and then wrap that function into a slice_rgb - but that would only let you 3 plot 3 of your data-sets.


Thank you sir.. I tried using scatter but it didnt work good
The syms variable declaration is useless since you instantly generate numerical variables with the same names. You might take a look at the help of isosurface and see that you can take the output from that function and send it into the patch command, that way you might be able to controll the properties of the surfaces (edgecolor, facecolor, facealpha etc.). Further it seems completely unnecessary to plug all four plots into the same axes only, feel free to do that for a couple of iso-levels, then add a couple of subplots where you use the slice-function to plot various cuts through your volume.
I will try using your ideas sir.
Thank you

Sign in to comment.