2014-12-03 66 views
2

具体带状图当我使用stripchart功能基础R与GGPLOT2

stripchart(df[,1]~df[,3], 
     method="stack", vertical=FALSE, ylim=c(0.5,2.5), 
     group.names=levels(df[,3]), 
     xlab="Rang des différences dr", pch=18, cex=1.2) 

我能与库ggplot2同积我有了这个数据帧

df <- structure(list(rang = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 
     13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25.5, 25.5, 27.5, 
     27.5, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42.5, 
     42.5, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54.5, 54.5, 56, 
     57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 
     73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88 
    ), dr = c(164, 176, 260, 297, 308, 313, 327, 333, 339, 365, 396, 
     403, 404, 410, 413, 414, 422, 424, 440, 442, 443, 451, 477, 496, 
     530, 530, 546, 546, 548, 565, 567, 574, 576, 587, 590, 603, 619, 
     626, 629, 630, 642, 653, 653, 660, 667, 670, 677, 682, 689, 711, 
     716, 737, 763, 772, 772, 776, 778, 792, 794, 820, 835, 838, 842, 
     855, 861, 888, 890, 899, 906, 908, 969, 1011, 1046, 1058, 1069, 
     1072, 1074, 1100, 1153, 1348, 1368, 1432, 1468, 1516, 1612, 1712, 
     1714, 1731), signe = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 2L, 
     2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 
     1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 2L, 
     1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
     2L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 
     1L, 1L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 2L, 
     2L), .Label = c("negatif", "positif"), class = "factor")), .Names = c("rang", 
     "dr", "signe"), row.names = c(NA, -88L), class = "data.frame") 

与此图表? 我用geom_dotplot但我没有相同的情节。这个例子

ggplot(data = df, aes(y=df[,1], x=factor(df[,3]))) + 
geom_dotplot(binaxis = "y", dotsize = 0.5) + 
coord_cartesian(ylim=c(0, 88)) + 
scale_y_continuous(breaks=seq(0, 88, 1)) 

请帮助我!

回答

2

你要翻转坐标,并设定binwidth = 1得到同样的情节:

ggplot(data = df, aes(y=rang, x=factor(signe))) + 
    geom_dotplot(binaxis = "y", dotsize = 0.8, binwidth=1) + 
    coord_cartesian(ylim=c(0, 88)) + 
    scale_y_continuous(name='Rang des différences dr') + 
    scale_x_discrete(name='') + 
    coord_flip() + 
    theme_bw(base_size = 20) 
1

这是一起的,你在寻找什么行:

ggplot(df) + geom_point(aes(df[,1],df[,3])) + theme_bw() 
+1

可能,这将做太多。 'ggplot(data = df,aes(x = signe,y = rang))+ geom_point(shape = 23,fill =“black”)+ coord_flip()' – jazzurro 2014-12-03 15:43:34