ggplot中的密度曲线图
density curve plot in ggplot
我是 ggplot 的新手,我正在尝试绘制密度曲线。
这是我尝试使用的代码的简化版本:
ggplot(data=ind1, aes(ind1$V1)) +
geom_density(fill = "red", colour = "black") + xlim(0, 30)
我得到的密度曲线图是这样的:
enter image description here
我不明白这里有什么问题!有人知道哪里出了问题吗?
使用调整参数。
ggplot(data=iris, aes(iris$Sepal.Length)) +
geom_density(fill = "red", colour = "black",adjust=3) + xlim(0, 30)
这样您就可以比较参数如何影响平滑:
ggplot(data=iris, aes(iris$Sepal.Length)) +
geom_density(fill = "red", colour = "black",adjust=1/2) + xlim(0, 30)
尝试几个不同的值(我认为略大于 1 会产生您想要的结果)。
我是 ggplot 的新手,我正在尝试绘制密度曲线。 这是我尝试使用的代码的简化版本:
ggplot(data=ind1, aes(ind1$V1)) +
geom_density(fill = "red", colour = "black") + xlim(0, 30)
我得到的密度曲线图是这样的: enter image description here
我不明白这里有什么问题!有人知道哪里出了问题吗?
使用调整参数。
ggplot(data=iris, aes(iris$Sepal.Length)) +
geom_density(fill = "red", colour = "black",adjust=3) + xlim(0, 30)
这样您就可以比较参数如何影响平滑:
ggplot(data=iris, aes(iris$Sepal.Length)) +
geom_density(fill = "red", colour = "black",adjust=1/2) + xlim(0, 30)
尝试几个不同的值(我认为略大于 1 会产生您想要的结果)。