2017-07-26 5 views
1

私は各青い点をグループごとに対応する赤い点に接続しようとしています。しかし、私はgeom_segmentを使って問題があります。ヘルプThx。グループ化されたポイントをggplot2に1行ずつ接続します。

repl <- data.frame(title = c("A", "B", "C", "A", "B", "C"), diff = c(10.06, -1.89, 12.79, 10.06, -1.89, 12.79), id = c(1:6), acc= c(43, 50, 44, 43, 50, 44), variable= c(rep("A", 3), rep("B", 3)), value=c(43,50,44,53,48,56)) 


ggplot(repl, aes(value, title, y=reorder(title, diff), group=variable, color=variable)) + 
    geom_point(size=2, shape=8)+ 
    geom_segment(aes(xend=value, x=value, y=title, yend=title), col='gray') 

enter image description here

各グループのために、私はそれをどのように行う必要があり、横に2点を結ぶ線があるはず?

+0

'variable'またはその間に行を接続しますか? –

答えて

1

これは行う必要があります。

ggplot(repl, aes(x = value, y = reorder(title, diff), 
       group = title, color = variable)) + 
    geom_point(size = 2, shape = 8)+ 
    geom_line(col = 'gray') 

EDIT:

何をしたいが故にvariableによってgroup = titlecolor = variable美学をそれらを着色しながら、titleでポイントを接続することです。

+0

OPのコードで問題をどのように解決したか説明を追加してください。 –

関連する問題