title: Log axis labels in ggplot2: Show only necessary digits?
body: <p>I would like to make a graph in ggplot2 with the x-axis on the log10 scale and the labels in regular rather than scientific notation with a minimum number of decimals. This means I would like to show 0.1 as 0.1 rather than 0.10 and 100 as 100 rather than 100.00.  </p>
  
  <p>I tried </p>
  
  <pre><code>df = data.frame(x =  c(1:10 %o% 10^(-3:2)), y = rnorm(60))
  
  ggplot(df, aes(x=x, y=y))+
        geom_point()+scale_x_log10(labels=comma)
  </code></pre>
  
  <p>Unfortunately, this shows to many decimals. </p>
  
  <p>@BenBolker answered a similar <a href="https://stackoverflow.com/questions/21056279/log-axis-labels-in-ggplot2-full-number-without-comma?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa">question</a> previously and his code works fine for numbers without decimals, but if there are numbers smaller than 1 it seems to give the same results as labels=comma. </p>
  
  <pre><code>plain &lt;- function(x,...) {
    format(x, ..., scientific = FALSE, trim = TRUE)
  }
  
  ggplot(df, aes(x=x, y=y))+
    geom_point()+scale_x_log10(labels=plain)
  </code></pre>