title: how to use jitter in geom_point on a barplot r
body: <p>I tried to draw a barplot with jitter points by different colors. I can draw the plot with geom_segment but I would like to use jitter points instead of lines (segments). This is my code:</p>
  
  <h1>data for barplot</h1>
  
  <pre><code>    dat = read.table(text="chromosome    size
           1  640851
           2  947102
           3 1067971
           4 1200490
           5 1343557
           6 1418242
           7 1445207
           8 1472805
           9 1541735
          10 1687656
          11 2038340
          12 2271494
          13 2925236
          14 3291936", header=T, stringsAsFactors=F)
  </code></pre>
  
  <h1>create a demo data set "mark" to draw jitter points.</h1>
  
  <pre><code>    pos = read.table(text="Chromosome Position
           3   817702
           5  1041685
          11   488717
          12  1556936
          13  1131566
          14  1776463", header=T, stringsAsFactors=F)
  
      mark &lt;- data.frame()
      for (i in 1:nrow(pos)){ 
          df &lt;- data.frame(Chr=rep(pos$Chromosome[i],100),Pos=sort(sample.int(pos$Position[i],100)))
          mark &lt;- rbind(mark,df)
          }
      mark &lt;- mark[order(mark$Chr,mark$Pos),]
      pp &lt;- replicate(6, diff(c(0, sort(runif(2)), 1)))
      pp &lt;- round(pp %*%diag(pos$Position),0)
      pp[2,] &lt;- pp[2,] +pp[1,]
      pp[3,] &lt;- pp[2,]+pp[3,]
      type &lt;-  replicate(6,sample(LETTERS[1:3],3))
      for (i in 1:length(unique(mark$Chr))){
        for (j in 1:100){
          if (mark$Pos[(i-1)*100+j] &gt;0 &amp; mark$Pos[(i-1)*100+j] &lt;= pp[1,i]) {mark$Type[(i-1)*100+j] &lt;- type[1,i]}
          if (mark$Pos[(i-1)*100+j] &gt;pp[1,i] &amp; mark$Pos[(i-1)*100+j] &lt;= pp[2,i]) {mark$Type[(i-1)*100+j] &lt;- type[2,i]}
          if (mark$Pos[(i-1)*100+j] &gt;pp[2,i] &amp; mark$Pos[(i-1)*100+j] &lt;= pp[3,i]+1) {mark$Type[(i-1)*100+j] &lt;- type[3,i]}
        }
      }
  </code></pre>
  
  <p>draw barplot with segments: </p>
  
  <pre><code>    ggplot(data=dat, aes(chromosome, size)) +
          theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
          panel.background = element_blank(), axis.line = element_line(colour = "black")) + 
          geom_bar( stat="identity", fill="grey70") +
        geom_segment(data=mark, aes(x=Chr-0.45, xend=Chr+0.45, y=Pos, 
                         yend=Pos, colour=Type), size=2)
  </code></pre>
  
  <p>I would like to draw barplot with jitter points. When I use geom_point to replace geom_segment. jitter is actually on "dat" data instead of "mark" data. This is not what I want. I want to have barplot with jitter points on "mark" data. 
  this is the code I used to draw the plot:</p>
  
  <pre><code>    ggplot(data=dat, aes(chromosome, size)) +
        theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
          panel.background = element_blank(), axis.line = element_line(colour = "black")) + 
        geom_bar( stat="identity", fill="grey70") +
        geom_point(data=mark, aes(x=Chr, y=Pos, colour=Type), size=1) + geom_jitter(width=0.5)
  </code></pre>
  
  <p>Thank you for any helps.</p>