title: Colour-coded 3D Plot in R
body: <p>I am new to R, so can someone please help with this?</p>
  
  <p>I have a data frame with 4 columns: x,y,z and freq. One row in this frame represents one point in 3D space (x,y,z are x-,y- and z- coordinates respectively) and it's frequency. I want to plot these points and make these points coloured such that the color is decided by the frequency. For eg: All points with frequency 0 are blue, between 1 and 5 are red, between 5 and 10 are orange, between 10 and 15 are yellow and so on. Some points can have a frequency of 0 also. But I don't know the range of frequency. Max no of colors to be used is 10. Also, there should be a scale explaining the meaning of colors. </p>
  
  <p>I have been trying to correct the following code and make it work, but it`s just not working: </p>
  
  <pre><code>lev &lt;- levels(factor(t$freq)); 
  n &lt;- as.numeric(lev); 
  n &lt;- n+1; 
  plot3d(t$x,t$z,t$z,col=n);
  </code></pre>
  
  <p>Please help! Thank you.</p>
  
  <p>PS- Please tell the solution using rgl package
  PPS - I have been trying to manipulate the col arguement in plot3d function of rgl package, but I am unable to get the desired result.</p>