ggplot2和geom_density:如何删除基线? [英] ggplot2 and geom_density: how to remove baseline?
问题描述
我正在使用 ggplot
,如此处所述
http://docs.ggplot2.org/current/stat_density.html
并进入R控制台
m < - ggplot(movies,aes(x = rating))
m + geom_density()
这个方法有效,但是有一些方法可以去除x轴和密度图(连接密度图到x轴的垂直线)
最一致的方法是(感谢@baptiste):
m + stat_density(geom =line)
我最初的建议是使用 geom_line
和适当的 stat
:
m + geom_line(stat =density)
但不再推荐,因为我收到的报告是n对于新版本的ggplot中的每一种情况,通用工作。
I'm using ggplot
as described here
http://docs.ggplot2.org/current/stat_density.html
and entered in the R console
m <- ggplot(movies, aes(x = rating))
m + geom_density()
This works but is there some way to remove the connection between the x-axis and the density plot (the vertical lines which connect the density plot to the x-axis)
The most consistent way to do so is (thanks to @baptiste):
m + stat_density(geom="line")
My original proposal was to use geom_line
with an appropriate stat
:
m + geom_line(stat="density")
but it is no longer recommended since I'm receiving reports it's not universally working for every case in newer versions of ggplot.
这篇关于ggplot2和geom_density:如何删除基线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!