title: Differences in bin values between cut and geom_histogram R
body: <p>I was looking to plot the location of local minima on a histogram. I used the following code to look at the data and find a local minima:</p>
  <pre><code>bins = cut(Seurat_obj$nCount_RNA, 
               breaks = seq(0, max(Seurat_obj$nCount_RNA) + dist, by = dist))
    
  bin_counts_table = table(bins)
  bin_counts = as.vector(bin_counts)
  names(bin_counts) = names(bin_counts_table)
  print(data.frame(bin_counts))
  </code></pre>
  <p>This gives me the following data frame:</p>
  <p><a href="https://i.stack.imgur.com/oClcX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oClcX.png" alt="enter image description here" /></a></p>
  <p>I then used the following code to plot the histogram:</p>
  <pre><code>  p = ggplot(Seurat_obj@meta.data, aes(x=nCount_RNA)) + 
      geom_histogram(binwidth=dist) +
      geom_vline(aes(xintercept=1500), #hardcoded here but I have code to determine this
              color=&quot;blue&quot;, linetype=&quot;dashed&quot;, size=1) +
    scale_x_continuous(breaks=seq(0, max(Seurat_obj$nCount_RNA)+dist, by = 3*dist))
  </code></pre>
  <p>This gives me the following plot:</p>
  <p><a href="https://i.stack.imgur.com/Qeak7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qeak7.png" alt="enter image description here" /></a></p>
  <p>Is there some diffrence between cut and geom_histogram that is changing the way the bins are calculated? Why are the minima diffrent?</p>