2014-06-14 139 views
-1

我正在使用ggplot來創建我的數據密度圖。但我想要得到直到2.0的X值的圖。 如何將這個殘留物放入我的代碼中?如何使用ggplot爲繪圖設置x軸的上限?

這裏是我的代碼和劇情:

ggplot()+geom_density(aes(data=Ge,x=GeN[,1]),color='red') 

enter image description here

+0

什麼是'Ge'和'GeN'?這不是使用'ggplot'的方法。如果GeN的第一列有x值,並且我們假設該列被命名爲X1,則使用'ggplot(GeN)+ geom_density(aes(x = X1),color =「red」)+ xlim(0,2 )' – jlhoward

回答

1
ggplot(iris, aes(x = Petal.Length)) + geom_density() 

enter image description here

ggplot(iris, aes(x = Petal.Length)) + geom_density() + xlim(0, 2) 

enter image description here