how to plot a multiple 4d array on same graph

1 view (last 30 days)
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
  2 Comments
KSSV
KSSV on 10 Jul 2019
Attach your data and show us your expectations.
priya nair
priya nair on 10 Jul 2019
The following is my data and i need to show all these four plots in a single graph
clc
clear all
syms x1 x2 y
[x1,x2,y] = ndgrid(linspace(-pi,0,120),linspace(0,pi/2,120),linspace(-pi,0,120));
f=(1+(-x1-x2).^(3/2)+3*abs(y).^3).^(-2).*(2*x1+2*x2+y+x1.*y+(1/2)*x2.*y
-((2+3*sqrt(2))/12)*x1.*x2.*y...
+((3+sqrt(2))/2)*x1.^2+ ((16+2*sqrt(2))/3)*x1.*x2+((1-sqrt(2))/6)*x2.^2....
+((38+15*sqrt(2))/72)*x1.^2.*y);
isosurface(x1,x2,y,f,0.01);
hold on
[x1,x2,y] = ndgrid(linspace(-pi,0,120),linspace(0,pi/2,120),linspace(-pi,0,120));
f=(1+(-x1-x2).^(3/2)+3*abs(y).^3).^(-2).*(2*(x1+x2)+y+x1.*y+(4/3)*x1.*x2.*y...
+((19+6*sqrt(2))/72)*x1.^4.*x2.^2+((20+9*sqrt(2))/72)*x1.^5.*x2
+((3+2*sqrt(2))/72)*x1.^4.*y+((2+sqrt(2))/9)*x1.^2.*x2.*y);
isosurface(x1,x2,y,f,0.01);
hold on
[x1,x2,y] = ndgrid(linspace(-pi,0,120),linspace(0,pi/2,120),linspace(-pi,0,120));
f=2*(x1+x2)+y+x1.*y+(1/2)*x2.*y-((2+3*sqrt(2))/12)*x1.*x2.*y...
+((3+sqrt(2))/2)*x1.^2+ ((16+2*sqrt(2))/3)*x1.*x2;
isosurface(x1,x2,y,f,0.01);
[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....
+((8+sqrt(2))/6)*x1.^2.*y+(4/9)*x2.^2.*y+y.^2;
isosurface(x1,x2,y,f,0.01);
hold off

Sign in to comment.

Accepted Answer

Bjorn Gustavsson
Bjorn Gustavsson on 10 Jul 2019
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:
scatter3(x1,x2,y,z1,z2,'filled')
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.
  3 Comments
Bjorn Gustavsson
Bjorn Gustavsson on 10 Jul 2019
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.
priya nair
priya nair on 11 Jul 2019
I will try using your ideas sir.
Thank you

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!