title: how to set limits on rounded facet wrap y axis?
body: <p>I have this plot and I need to round the y axis so what appears is acceptable EXCEPT for the fact that I would like to not just show 1 value on the y axis. I'd like to add the "limit" to the "scale_y_continuous" function so that the limits for each facet plot are unique to the individual facet.</p>
  
  <p>here is the plot only showing 60 and 80 on the y axis</p>
  
  <pre><code>dat = data.frame(x = c(1,2,3,1,2,3),A=c(80.6, 82,83,60,61,62),A_up =c(81,84,85,62,63,64), A_low =c(79,78,81,59,58,57), group = c("z","z","z","y","y","y"))
  ggplot(data=dat , aes(x=as.factor(x), y=A, group = 1)) + #, color =Group, group = Group 
    geom_line()  + geom_point() + # facet_wrap(~COUNTERPARTY_STRATEGY ,ncol=2)
    geom_errorbar(aes(ymax = A_up ,ymin = A_low), width = .25) +
       scale_y_continuous(breaks = seq(  floor(  (min(dat$A_low)-11)  /10)*10 ,
                                     ceiling(  (max(dat$A_up)+11) /10)*10,10 ),
                        labels = seq(  floor(  (min(dat$A_low)-11)  /10)*10 ,
                                     ceiling(  (max(dat$A_up)+11) /10)*10,10 )
                        ) +
      facet_wrap(~group ,ncol=2, scales = "free_y") 
  </code></pre>
  
  <p>Now I add the limit in the scale y continuous and it applies the limit globally.</p>
  
  <pre><code>dat = data.frame(x = c(1,2,3,1,2,3),A=c(80.6, 82,83,60,61,62),A_up =c(81,84,85,62,63,64), A_low =c(79,78,81,59,58,57), group = c("z","z","z","y","y","y"))
  ggplot(data=dat , aes(x=as.factor(x), y=A, group = 1)) + #, color =Group, group = Group 
    geom_line()  + geom_point() + # facet_wrap(~COUNTERPARTY_STRATEGY ,ncol=2)
    geom_errorbar(aes(ymax = A_up ,ymin = A_low), width = .25) +
       scale_y_continuous(breaks = seq(  floor(  (min(dat$A_low)-11)  /10)*10 ,
                                     ceiling(  (max(dat$A_up)+11) /10)*10,10 ),
                        labels = seq(  floor(  (min(dat$A_low)-11)  /10)*10 ,
                                     ceiling(  (max(dat$A_up)+11) /10)*10,10 ),
                       # limits =  c( floor(  min(dat$A_low[dat$group =="z"])  /10)*10 ,ceiling(max(dat$A_up[dat$group =="z"])/10)*10 )   
                        #limits =  c( floor(  min(dat$A_low[dat$group =="z"])  /10)*10 ,ceiling(max(dat$A_up[dat$group =="z"])/10)*10 ) 
                        limits =  c( floor(  min(dat$A_low)  /10)*10 ,ceiling(max(dat$A_up)/10)*10 ) 
                        ) +
      facet_wrap(~group ,ncol=2, scales = "free_y") 
  </code></pre>
  
  <p>i.e. </p>
  
  <p><code>c( floor(  min(dat$A_low)  /10)*10 ,ceiling(max(dat$A_up)/10)*10 )</code></p>
  
  <p>is 50 and 90</p>
  
  <p>but I would like the limit to be unique to each facet plot so something like</p>
  
  <p>so the right plot would have limits of </p>
  
  <p><code>c( floor(  min(dat$A_low[dat$group =="y"])  /10)*10 ,ceiling(max(dat$A_up[dat$group =="y"])/10)*10 )</code></p>
  
  <p>50 and 70 </p>
  
  <p>and the left plot would have limit of </p>
  
  <p><code>c( floor(  min(dat$A_low[dat$group =="z"])  /10)*10 ,ceiling(max(dat$A_up[dat$group =="z"])/10)*10 )</code></p>
  
  <p>70 and 90</p>
  
  <p>how can the limits be adjusted to be specific to the individual facet plots?</p>