title: how to do 3D number-density scatter plot using given data?
body: <p>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.</p>
  
  <p>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. </p>
  
  <pre><code>%reading the files
  [FileName,PathName,FilterIndex] = uigetfile('H:\*.txt','MultiSelect','on');
  numfiles = size(FileName,2);%('C:\final1.txt');
  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);
      %% I DON'T KNOW HOW TO CREAT THIS LOOP TO COUNT FOR THE NUMBER OF PARTICLES WITHIN EACH DEFINED CUBE %%
      for jj = 2:size(X,2) 
          %for kk=1:m
          if x(:)&lt;X(jj) &amp; y(:)&lt;X(jj) &amp; z(:)&lt;X(jj)
             x;
          end
          %end
      end
      h=figure(j);
      scatter3(x, y, z, 'filled', 'MarkerSize', 20);
      cb = colorbar();
      cb.Label.String = 'Probability density estimate';
  end
  </code></pre>
  
  <p>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.</p>
  
  <p>Here is a link to a sampled data. </p>