% parallel coordinate 2D circle
% with random theta
clf
clear all

xcenter=.50; ycenter=.50; zcenter=.50;
npoints=400;
fudge = .00;

rfract=.5;
for i = 1:npoints;
   theta=rand*2*pi; 
   r(i)=rfract+(1-rfract)*rand;
   position(1,i)= ((r(i)*cos(theta)+1)/2);  %x
   position(2,i)= ((r(i)*sin(theta)+1)/2) ;  %y 
end

map=jet(10) ;
%s=r;
xoffset=0.5; yoffset=0.5;
s=sqrt((position(1,:)-xoffset).^2 +...
   (position(2,:)-yoffset).^2 );
s = 10*(s - min(s))/(max(s)-min(s))+1 ;
%s=0*s+1;


subplot(3,1,1)

hold on
for i = 1:npoints
    if (s(i)<12)
        cindex = min( fix(s(i)), 10);
        plot(position(:,i), 'color', map(cindex,:) ); 
    end
end
  

axisx = [1,3; 1,1; 2,2; 3,3]';
axisy = [0,0; 0,1; 0,1; 0,1]';
line(axisx, axisy, 'color', 'k');

%==========================

subplot(3,1,2)
axis([0 1 0 1])
set(gca,'color','white')
set(gca,'position',[0 .4 .60 .25]);
hold on
for i = 1:npoints
    cindex = min( fix(s(i)), 10);
    plot(position(1,i),position(2,i),...
       'color', map(cindex,:),...
        'markersize',1.5,'linewidth',3,'marker','o')
  end
  
  %======================
  %density histogram

  subplot(3,1,3)
  
  xstep=10; ystep=20;
  density=zeros(xstep+1,ystep);
  
  for i = 1:npoints
     %plot(position(:,i), 'color', map(cindex,:) ); 
     %position(1,i)=fix((position(1,i))*ystep)+1;
     %position(2,i)=fix((position(2,i))*ystep)+1;
     
     for x=0:1/xstep:1%-1/xstep
        y =position(1,i)+...
           x*(position(2,i)-position(1,i));
        xindex= fix(x*xstep)+1;
        yindex= fix(y*ystep)+1;
        density(xindex,yindex)=...
           density(xindex,yindex)+1;
     end    
  end
  mask=[1/4 1/2 1/4; ...
        1/2 1   1/2; ...
        1/4 1/2 1/4;];
  
  density=filter2(mask,density);
  contourf(density',10);
  set(gca,'position',[0 0 .5 .33]);
  
  
  