2017-07-12 40 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