2017-08-04 8 views
1

にすべてのポイントを怒鳴るのは、私がレンダリングこのプロットはggplot2の散布図

iris2 <- iris %>% data.table 
iris2 <- iris2[Sepal.Length<6] 
iris2[,Sepal.Width:=mean(Sepal.Width),by=Sepal.Length] 
iris2 %>% ggplot(aes(x=Sepal.Length,y=Sepal.Width,color=Species,group=Species)) + 
    geom_line() + geom_point() 

あるとしましょう:

enter image description here

どのように軸を追加することができますがティックとラベルを付けて、あらゆる点に対応するティックとラベルを付けます。

答えて

2

x軸が離散的でないため、あなたが望むものを実現するには、scale_x_continuousを使用する必要があります。次のコードは動作するはずです:

iris2 %>% 
    ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species, group = Species)) + 
    geom_line() + 
    geom_point() + 
    scale_x_continuous(breaks = unique(iris$Sepal.Length))