2017-07-12 124 views
-1

请问,有没有人知道如何去除x轴上的这条彩色线?数据框是dfp如何用ggplot2中的geom_density去除x轴上的彩色线?

    Value   Class 
    1    94.00    A 
    2    70.51    A 
    3    70.02    A 
    4    95.24    A 
    5    70.53    A 
    6    93.01    A 
    7    70.86    A 
    8    94.84    A 
    9    70.77    A 

I'm使用此命令行来绘制:

ggplot(dfp, aes(na.omit(dfp$Value), color = na.omit(dfp$Class), alpha=0.3)) + geom_density(size=1.5) 

enter image description here

+0

重复的:https://stackoverflow.com/questions/21600754/ggplot2-and-geom-density-how-to-remove-baseline?rq=1 – Brian

回答

1
ggplot(...) + stat_density(geom = "line") 

默认geomarea,但你可以将其更改为line。默认的好处是可以遮蔽该区域(具有fill =美学),而不是勾勒它的轮廓。

0

您应该使用geom_freqpoly()而不是geom_density()

最佳,

科林

+0

谢谢!但我需要频率密度。看起来'geom_freqpoly()'仅适用于离散值,对吧? – Bindini