title: Fit line to data on a log scale in R
body: <p>Basically, I don't know how to plot a line of best fit on my data once it's a logarithmic scale. I put a linear regression trend line on my plot using lm() and abline(), but now that log="xy" has been added this just produces a horizontal line.</p>
  
  <p><img src="https://i.stack.imgur.com/n8zia.png" alt="enter image description here"></p>
  
  <p>Here's a very simplified example of what I'm trying to do (the line is completely missing here, however):</p>
  
  <pre><code>lengths = c(10000,3000,3005,3005,3010,20000)
  counts = c(3,1,1,2,1,3)
  line=lm(counts~lengths)
  plot(lengths, counts, col="green", log="xy")
  abline(line, col="blue")
  </code></pre>
  
  <p>I've tried lots of things I've found on similar questions (e.g. using <code>log10()</code> and <code>lines()</code>) and they haven't worked with my data.</p>