geom_dotplot错误的点数

Ign*_*cio 3 r ggplot2

我的数据如下:

df.plot <-structure(list(color = structure(c(2L, 2L, 3L, 1L, 3L, 4L, 3L, 
                                             1L, 4L, 1L, 2L, 4L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 3L, 2L, 
                                             3L, 3L, 3L, 3L), .Label = c("54", "55", "61", "69"), class = "factor"), 
                         date = structure(c(16687, 16687, 16687, 16687, 16687, 16687, 
                                            16688, 16688, 16688, 16689, 16689, 16690, 16693, 16693, 16693, 
                                            16694, 16694, 16695, 16695, 16695, 16695, 16696, 16696, 16696, 
                                            16696, 16696, 16696), class = "Date"), facet = c("A", 
                                                                                             "A", "A", "A", "A", "B", 
                                                                                             "B", "A", "B", "B", "B", "B", 
                                                                                             "B", "B", "B", "B", "A", "B", 
                                                                                             "A", "B", "A", "C", "B", "C", 
                                                                                             "C", "B", "C")), class = "data.frame", row.names = c(NA, 
                                                                                                                                                                  -27L), .Names = c("color", "date", "facet"))
Run Code Online (Sandbox Code Playgroud)

下表总结了每个构面/颜色的观察数量

df.plot %>% group_by(facet, color) %>% summarise(n())

---------------------
  facet   color   n() 
------- ------- -----
A      54      5  
A      55      2  
A      61      2  
B      54      6  
B      55      3  
B      61      2  
B      69      3  
C      61      4  
---------------------    
Run Code Online (Sandbox Code Playgroud)

ggplot生成此图:

ggplot(df.plot, aes(x=date, fill=color)) + 
  geom_dotplot(binwidth=1) +
  coord_fixed(ratio=1) + 
  ylim(0,7) +
  facet_grid(facet ~ .) 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

为什么分数错了?例如,我希望A 54有5分,而情节只有4分.

bee*_*oot 9

不同颜色但相同日期的点重叠.添加stackgroups=TRUE应该给出预期的结果:

ggplot(df.plot, aes(x=date, fill=color)) + 
  geom_dotplot(binwidth=1, stackgroups=TRUE) +
  coord_fixed(ratio=1) + 
  ylim(0,7) +
  facet_grid(facet ~ .) 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述