I have a cubic box with the size of, lets say 300 in each direction. I have some data (contains X,Y,Z coordinates) which represent the distribution of nearly 1 million data-points within this box. I want to specify a color to their Number density (its an intensive quantity used to describe the degree of concentration of countable objects in this case data-points). In another word, Using color to illustrate which part is more condensed in terms of data-points rather than the other parts. The index for the color-bar in the final image should represent the percentage of data-points specified with that color.
I have tried to do it by dividing the whole space in cubic box to 1 million smaller cube (each cube has a length of 3 in all direction). By counting the number of particles within those cube, I will know how they distributed in the box and the number of existed data-points within. Then I can specify a color to them which I wasn’t successful in counting and specifying. Any suggestion is appreciated.
%reading the files
[FileName,PathName,FilterIndex] = uigetfile('H:\*.txt','MultiSelect','on');
numfiles = size(FileName,2);
j=1;
X=linspace(0,300,100);
for ii = 1:numfiles
FileName{ii}
entirefile = fullfile(PathName,FileName{ii});
a = importdata(entirefile);
x = a(:,2);
y = a(:,3);
z = a(:,4);
for jj = 2:size(X,2) % loop over all points
if x(:)<X(jj) & y(:)<X(jj) & z(:)<X(jj)
x;
end
end
h=figure(j);
scatter3(x, y, z, 'filled', 'MarkerSize', 20);
cb = colorbar();
cb.Label.String = 'density estimate';
end
I need to get a similar result like the following image. but I need the percentage of data-point specified by each color. Thanks in advance.

1 commentaire

Tiger6
Tiger6 le 5 Août 2019
Modifié(e) : Tiger6 le 12 Août 2019
Here is the link to the data

Connectez-vous pour commenter.

 Réponse acceptée

darova
darova le 5 Août 2019

1 vote

1Untitled.png
C = x*0;
for i = 1:length(x)
v = (abs(x-x(i)) < R) & (abs(y-y(i)) < R) & (abs(z-z(i)) < R); % how many points in cube
% v = (x-x(i)).^2 + (y-y(i)).^2 + (z-z(i)).^2 < R^2; % or sphere
C(i) = sum(v)-1; % number of points except x(i)
end
scatter3(x,y,z,10,C)
You can also visualize your data with contourslice()

9 commentaires

darova
darova le 5 Août 2019
DOes this help you? Can you please accept the answer?
darova
darova le 5 Août 2019
Doesn't look like your image :(
iimg.png
Tiger6
Tiger6 le 6 Août 2019
@darova Its looklike mine but just from a different angle. I need the percentage of data-point specified by each color. the sum of all the index in the color-bar should represent the total number of our data-points. Do you know how can I do it?
Tiger6
Tiger6 le 6 Août 2019
contourslice()
Can you visualize it with this function? In manual of using this function says:
"contourslice(X,Y,Z,V,xslice,yslice,zslice) draws contours in slices for the volumetric data V, where V determines the contour colors. "
how should I define V?
Thanks in advance.
darova
darova le 6 Août 2019
I just picked some points using Data Cursor to create a plane
img1.png
Created the plane. But it doesn't look good
img0.png
darova
darova le 6 Août 2019
'I need the percentage of data-point specified by each color'
colorbar?
Tiger6
Tiger6 le 6 Août 2019
Yes, the color-bar index, should represent the number of data-points specified in that color.
If a color allocated to a place in the box where data-points are exist, I want to know the number of points or the percentage of those data-points specified in that color.
Vector C has number of neighbour points for specified radius
C(i) = sum(v)-1;
For example: radius = 5
img1.png
If you want percentage
img0.png
scatter3(x,y,z,5,C/max(C)*100,'fill') % percentage
Tiger6
Tiger6 le 6 Août 2019
@darova Thanks for your time and kind consideration.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by