title: ggplot boxplot - length of whiskers with logarithmic axis
body: <p>I'm trying to create a horizontal boxplot with logarithmic axis using ggplot2. But, the length of whiskers are wrong.</p>
  
  <p>A minimal reproducible example:</p>
  
  <p>Some data</p>
  
  <pre><code>library(ggplot2)
  library(reshape2)
  set.seed(1234)
  my.df &lt;- data.frame(a = rnorm(1000,150,50), b = rnorm(1000,500,150))
  my.df$a[which(my.df$a &lt; 5)] &lt;- 5
  my.df$b[which(my.df$b &lt; 5)] &lt;- 5
  </code></pre>
  
  <p>If I plot this using base R <code>boxplot()</code>, everything is fine</p>
  
  <pre><code>boxplot(my.df, log="x", horizontal=T)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/kQLU6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kQLU6.png" alt="enter image description here"></a></p>
  
  <p>But with ggplot,</p>
  
  <pre><code>my.df.long &lt;- melt(my.df, value.name = "vals")
  ggplot(my.df.long, aes(x=variable, y=vals)) +
    geom_boxplot() +
    scale_y_log10(breaks=c(5,10,20,50,100,200,500,1000), limits=c(5,1000)) +
    theme_bw() + coord_flip()
  </code></pre>
  
  <p>I get this plot, in which the whiskers are the wrong length (see for example how there are many additional outliers below the whiskers and none above).</p>
  
  <p><a href="https://i.stack.imgur.com/jmnLW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jmnLW.png" alt="enter image description here"></a></p>
  
  <p>Note that, without log axes, ggplot has the whiskers the correct length</p>
  
  <pre><code>ggplot(my.df.long, aes(x=variable, y=vals)) +
    geom_boxplot() +
    theme_bw() + coord_flip()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/HDMSb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HDMSb.png" alt="enter image description here"></a></p>
  
  <p>How do I produce a horizontal logarithmic boxplot using ggplot with the correct length whiskers? Preferably with the whiskers extending to 1.5 times the IQR.</p>
  
  <p><strong>N.B.</strong> as explained <a href="https://stackoverflow.com/a/3388026/2761575">here</a>. It is possible to use <code>coord_trans(y = "log10")</code> instead of <code>scale_y_log10</code>, which will cause the stats to be calculated <em>before</em> transforming the data. <em>However</em>, <code>coord_trans</code> cannot be used in combination with <code>coord_flip</code>. So this does not solve the issue of creating horizontal boxplots with a log axis.</p>