title: scatter plot specifying color and labelling axis in r
body: <p>I have following data and plot:</p>
  
  <pre><code>pos &lt;- rep(1:2000, 20)
  xv =c(rep(1:20, each = 2000))
  # colrs &lt;- unique(xv)
  colrs &lt;- xv # edits 
  yv =rnorm(2000*20, 0.5, 0.1)
  
  xv   = lapply(unique(xv), function(x) pos[xv==x])
  to.add = cumsum(sapply(xv, max) + 1000)
  
  bp &lt;- c(xv[[1]], unlist(lapply(2:length(xv), function(x) xv[[x]] + to.add[x-1])))
  plot (bp,yv, pch = "*", col = colrs)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/DehcO.jpg" alt="enter image description here"></p>
  
  <p>I have few issues in this plot I could not figure out.</p>
  
  <p>(1) I want to use different color for different group or two different color for different groups (i.e xv), but when I tried color function in terms to be beautiful mixture. Although I need to highlight some points (for example bp 4000 to 4500 for example with blue color)</p>
  
  <p>(2) Instead of bp positions I want to put a tick mark and label with the group.</p>
  
  <p>Thank you, appreciate your help. </p>
  
  <p>Edits: with help of the following answer (with slight different approach in case I have unbalanced number in each group will work) I could get the similar plot. But still question remaining regarding colors is what if I want to use two alternate colors in alternate group ? </p>