title: Dealing with factors in geom_pointrange in ggplot
body: <p>I am trying to visualize some data that consist of odds ratios and confidence intervals for regions nested in countries. I am using the geom_pointrange option for that and it general it works very well. </p>
  
  <p>My problem is that since the odds ratios (and upper confidence intervals) can get quite high values, the axes of the plot are stretched to accommodate for that. That has as a result that confidence intervals that lie between 0 and 1 do not appear clearly enough. One option I found through this community is to change the values into factors and the distance between them will be considered the same for every measurement. This works for the odds ratios (still need to tweak the axis tick marks) but when the values of lower and upper confidence intervals are involved, the position is totally wrong and the confidence intervals do not include the point estimate. I tried to solve this by including all values as levels of the factor, but this did not seem to solve the issue. </p>
  
  <p>What i am trying to do is either to be able to "magnify" the area between 0 and 1 in the graph, while leaving the rest of the plot area unchanged or to manage to make ggplot to place the confidence intervals correctly around the odds ratios. </p>
  
  <p>Below I include a simplified version of my data and the code I have been using for re-producibility. </p>
  
  <pre><code>dat &lt;- data.frame(region = rep(LETTERS[1:5], 2), 
                country = rep(c("A1", "A2"), each = 5), 
                or = c(6.459578, 1.696221, 0.895115, 3.393235, 2.325510, 
                       4.457805, 0.407111, 22.760861, 3.354883, 2.214915), 
                lower = c(5.768999699, 0.237062909, 0.347443105, 0.369881529, 
                          0.010233696, 1.020315696, 0.004419494, 3.87391259, 
                          0.808667764, 0.874415935), 
                upper = c(7.2328221, 12.1367207, 2.3060778, 31.1290104, 
                          28.4497981, 19.4763489, 0.750188, 337.2960785, 
                          13.9182469,    5.610429))
  
  library(ggplot2)
  
   ggplot(dat, aes(x = region, y = or, ymin = lower, ymax = upper))+
     geom_pointrange() +
     geom_hline(yintercept = 1, linetype = 2) +
     theme_bw() + 
     theme(plot.margin = unit(c(1, 1, 1, 4), "lines"),
           axis.title = element_blank(),
           axis.ticks.y = element_blank(),
           panel.grid.major = element_blank(),
           panel.grid.minor = element_blank(), 
           legend.position="none") + 
     facet_wrap(~ country) + 
     coord_flip(ylim = c(0, 100))
  
   # Change numeric variable into factors
   f.levels &lt;- c(dat$or, dat$lower, dat$upper)
   f.levels &lt;- unique(f.levels)
   f.levels &lt;- as.character(f.levels[order(f.levels)])
  
   dat$or &lt;- factor(dat$or, levels = f.levels)
   dat$lower &lt;- factor(dat$lower, levels = f.levels)
   dat$upper &lt;- factor(dat$upper, levels = f.levels)
  
   ggplot(dat, aes(x = region, y = or, ymin = lower, ymax = upper))+
      geom_pointrange() +
      geom_hline(yintercept = 1, linetype = 2) +
      theme_bw() + 
      theme(plot.margin = unit(c(1, 1, 1, 4), "lines"),
            axis.title = element_blank(),
            axis.ticks.y = element_blank(),
            panel.grid.major = element_blank(),
            panel.grid.minor = element_blank(), 
            legend.position="none") + 
      facet_wrap(~ country) + 
      coord_flip(ylim = c(0, 30))
  </code></pre>
  
  <p>I am relatively new to ggplot so please excuse any newbie mistakes. 
  Any suggestions on this problem are highly appreciated. </p>
  
  <p>Thank you!</p>