Reputation: 1005
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))
Upvotes: 4
Views: 6766
Reputation: 2400
Alternatively, you can use adjust
.
plot(density(x$PLCO2, adjust = 2))
The docs say:
adjust
: the bandwidth used is actuallyadjust*bw
. This makes it easy to specify values like ‘half the default’ bandwidth.
Upvotes: 0
Reputation: 5314
you can make you density plot smoother by increasing the bandwidth (bw)
plot(density(x$PLCO2, bw = bw_bigger))
Upvotes: 4