title: Contour plot coloured by clustering of points matlab
body: <p>I have two vectors which are paired values</p>
  
  <pre><code>size(X)=1e4 x 1; size(Y)=1e4 x 1
  </code></pre>
  
  <p>Is it possible to plot a <code>contour plot</code> of some sort making the contours by the highest density of points?  Ie highest clustering=red, and then gradient colour elsewhere?</p>
  
  <p>If you need more clarification please ask.
  Regards,</p>
  
  <p>EXAMPLE DATA:</p>
  
  <pre><code>X=[53 58 62 56 72 63 65 57 52 56 52 70 54 54 59 58 71 66 55 56];  
  Y=[40 33 35 37 33 36 32 36 35 33 41 35 37 31 40 41 34 33 34 37 ];
   scatter(X,Y,'ro');
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/CcpjO.png" alt="enter image description here"></p>
  
  <p>Thank you for everyone's help.  Also remembered we can use <code>hist3</code>:</p>
  
  <pre><code>x={0:0.38/4:0.38}; % # How many bins in x direction
  y={0:0.65/7:0.65}; % # How many bins in y direction
  
  ncount=hist3([X Y],'Edges',[x y]);
  pcolor(ncount./sum(sum(ncount)));
  colorbar
  </code></pre>
  
  <p>Anyone know why <code>edges</code> in hist3 have to be cells?</p>