Search code examples
rsmoothingdensity-plot

Smooth a density plot so that it doesn't appear saw toothed


I have made a density plot in R. I want to get rid of the saw tooth pattern and have it be entirely smooth. The reason that it appears saw tooth is because the values of x$PLCO2 are all whole numbers. But I want to smooth the plot for aesthetic reasons. Any idea on how to do that?

plot(density(x$PLCO2))

Density Plot


Solution

  • you can make you density plot smoother by increasing the bandwidth (bw)

    plot(density(x$PLCO2, bw = bw_bigger))