title: How to get a smooth density curve over a discrete X axis?
body: <p>I have a discrete x-axis with a small number of levels. I want a smooth curve showing the distribution. When I keep <code>gear</code> as a factor I get bars which is not exactly what I'm looking for, and when I use <code>gear</code> as a numeric I get jagged looking distribution which is not exactly what I am looking for either.</p>
  
  <p>Does anyone have advice on showing a smooth distribution for discrete data?</p>
  
  <pre><code>library(tidyverse)
  
  mtcars %&gt;% 
    group_by(gear) %&gt;% 
    summarise(mpg = mean(mpg)) %&gt;% 
    ggplot(aes(factor(gear), mpg)) +
    geom_density(stat = "identity")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vi1at.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vi1at.png" alt="discrete_distribution"></a></p>