R 带有ggplot2的特定条形图

R 带有ggplot2的特定条形图,r,ggplot2,stripchart,R,Ggplot2,Stripchart,我有这个数据框 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, 4

我有这个数据框

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")
我可以使用库
ggplot2
进行相同的绘图吗? 我使用了
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))

请帮帮我

这是否符合您所寻找的内容:

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

您必须翻转坐标,并设置
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)

这可能也行<代码>ggplot(数据=df,aes(x=signe,y=rang))+geom_点(shape=23,fill=“黑色”)+coord_flip()
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)