Slice plot of a 3D-data set with color code

8 Ansichten (letzte 30 Tage)
Arne
Arne am 19 Nov. 2014
Kommentiert: Arne am 24 Nov. 2014
Hello,
I have a rather simple question - tried to reread other posts but it simply doesnt work out so far..
I have several thousands of points in a 3D field - each represented by X,Y and Z value. Each point is described by a fourth number. Coloring should be according to the value of the fourth variable.
I have done a 3D-scatter plot but chances are I miss out interesting things in the middle that are blocked out of my view.
Hence, I would have to do a compilation of slices to visualize the inside. Slice planes should go from the bottom of the 3D-figure to the top.
I know of the slice-function in matlab. But my input arguments produce errors I cannot interprete.
Can someone provide a sample code? Sadly, I could not find one before.
I know that it should be something like -> slice (X,Y,Z,V, PlanevectorX, PlanevectorY, PlanevectorZ)
what would be V in my case?
  1 Kommentar
Arne
Arne am 20 Nov. 2014
I have thought about this question a bit. Maybe it might be the easiest thing to separate the matrix into several smaller matrices according to their Z-value. For example Z ranges from -428 to -152. Then I divide the giant matrix into smaller ones; first one with Z-values from -425 to -400, next one with Z-values from -400 to -375, and so on.. And then actually plot the scatter3 plots of those - I guess I can separate the matrix with histc but I only did this for vectors.. any idea how to histc a matrix according to a column and then de-index them to get the small matrices?
Best

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Adam
Adam am 20 Nov. 2014
Bearbeitet: Adam am 21 Nov. 2014
I'm not familiar with the slice function, although it does look very useful for the work I do also, but I'm pretty sure that V should be your colour data, of the same size as the X, Y and Z data which should be provided using meshgrid e.g.
[X,Y,Z] = meshgrid(-2:.2:2,-2:.25:2,-2:0.1:2);
The parameterisation of meshgrid should match your sampling to give you X, Y, and Z matrices whose dimensions match your colour values.
  4 Kommentare
Adam
Adam am 21 Nov. 2014
The x, y, z in my comment above are now the same as your x, y, z. I changed naming convention from my original answer just to match the way the help names things.
X, Y and Z in my comment answer are the meshgrid outputs that I named x, y, z originally.
(I have now edited my original answer to use consistent variable naming)
Arne
Arne am 24 Nov. 2014
Thank you! I understand a little bit more now - I tried to create the meshgrid like you suggested:
[X,Y,Z] = meshgrid(my_x,my_y,my_z);
Unfortunately, I get an error message called: Error using repmat Out of memory. Type HELP MEMORY for your options.
Looks like the vecotors I have are too large for this operation (31147 lines).

Melden Sie sich an, um zu kommentieren.


matt dash
matt dash am 21 Nov. 2014
Answer to your updated comment: Use the second output (ind) of histc, which is the index of which bin the rows are in. Then use this to plot subsets of the data.
Example: see how data is binned according to the 4th column (which corresponds to color in the scatter plot)
data = rand(10000,4)
[counts,ind]=histc(data(:,4),[0 0.25 0.5 0.75 1]);
for i = 1:max(ind)
figure;
axes;
idx = ind==i;
scatter3(data(idx,1),data(idx,2),data(idx,3),16,data(idx,4),'filled')
set(gca,'clim',[0 1])
end

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by