每个彩色轨迹的3D绘图独立于开始到结束

问题描述 投票:0回答:1

我编写了一个程序,根据在显微镜上收集的图像中的轨道ID,帧数,x,y和z位置的输入,在3D中绘制轨迹。我所遇到的问题最好用这个image来说明。我希望每条轨道都能从蓝色到红色单独标记,彼此独立。下面的代码是将所有轨道中的色标链接到单个色条,以便短轨道全部为蓝色,而不是从红色到蓝色的光谱。我是MATLAB的初学者,所以请耐心等待我的编码。

我的数据组织如下:

Tracking    Frame   x    y    z
  1           1     2   151  -49
  1           2     31  139  -61
  1           3     32  113  -41
  2           8     1   10   -2
  2           9     3   28   -63
  2           10    4   25   -60
  2           11    1   20   -50
  2           12    8   20   -55 

除了每个轨道可能有多达几百个点。

我的代码如下:

input=FileName;  % Rename data for easier use

input.Properties.VariableNames= {'tracking'  'frame'  'x' 'y' 'z'}; 

Max_y=max(input.y)+10;      % This input is the x and y dimensions of the
                            % field of view from the raw data in nm which was analyzed.
Min_y=min(input.y)-10;
Max_x=max(input.x)+10;
Min_x=min(input.x)-10;

ExpsTime=.1;                % Exposure time from camera of raw data frames in seconds
minlength=2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%        
t=input.frame*ExpsTime;                % Convert frames to time
hold on;                               % plot multiple points and traces on the same graph 
set(gca,'Ydir','normal','FontSize',3);

n=1;                                    % loop counter for moving through different tracks
m=max(input.tracking)+1;                  % total number of different tracks

while n<m              % This loop takes the all the data labeled as a 
                       % single track from the varialbe "tracking" and
                       % plots by connecting the dots from just that track.
   ind1=input(input.tracking==n,:);     % Make subset of data for a single track
   b=size(ind1);                        % Calculates the length in frames of track 
   cnt=linspace(1,b(1),b(1));           % generate sequence of numbers for length of track to count frames within a track
   cnt=cnt';
   cnt=array2table(cnt);                
   ind1=[ind1 cnt];                     % Add info for frame counter to data subset


      if b(1)>minlength                 % Only plot if longer than minlength
       figs(n)= plot3(ind1.x,ind1.y,ind1.z,'-k','LineWidth',1.5);

          scatter3(ind1.x,ind1.y,ind1.z,40,ind1.cnt,'filled')
          axis([Min_x Max_x Min_y Max_y])
          colorbar

          n=n+1 
      else
          n=n+1  %If the track has less than minlength 
                 %number of frames than it is skipped over.
      end

end  
matlab 3d
1个回答
1
投票

正如@David在他的评论中所建议的那样,将每个散点图的强度在0到1之间进行缩放。您可以通过更新此行来实现:

scatter3(ind1.x,ind1.y,ind1.z,40,ind1.cnt,'filled')

到这一个:

scatter3(ind1.x,ind1.y,ind1.z,40,linspace(0,1,numel(ind1.cnt)).','filled')
© www.soinside.com 2019 - 2024. All rights reserved.