3

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

4

2 回答 2

4

您可以通过增加带宽(bw)使密度图更平滑

plot(density(x$PLCO2, bw = bw_bigger))
于 2015-03-04T21:34:23.157 回答
0

或者,您可以使用adjust.

plot(density(x$PLCO2, adjust = 2))

文档说:

adjust: 实际使用的带宽是adjust*bw. 这使得指定诸如“默认一半”带宽之类的值变得容易。

于 2020-01-10T13:29:26.480 回答