R 在ggplot2中刻面后几何图形点过多

R 在ggplot2中刻面后几何图形点过多,r,ggplot2,R,Ggplot2,运行下面的脚本,我希望六个术语中的每一个都有一个数据点,根据数据集的不同颜色,通过调整分面。然而,我每学期在每个方面都得到三分和四分。当数据集中只有24行时,你知道这是怎么发生的吗 library(ggplot2) tb5 <- structure(list(term = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L

运行下面的脚本,我希望六个术语中的每一个都有一个数据点,根据数据集的不同颜色,通过调整分面。然而,我每学期在每个方面都得到三分和四分。当数据集中只有24行时,你知道这是怎么发生的吗

library(ggplot2)   
tb5 <- structure(list(term = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 1L, 
    2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 6L, 1L, 2L, 3L, 4L, 5L, 
    6L), .Label = c("A", "B", "C", "D", "E", "F"), class = "factor"), 
        coef = c(-1.444, 0.035, -0.034, 0.005, 0.001, 2.43, -1.032, 
        0.032, -0.024, 0.025, 0.003, 1.758, -1.148, 0.02, 0.003, 
        0.027, 0.003, 12.713, -1.494, 0.028, -0.021, 0.007, 0.004, 
        13.499), ci.lb = c(-1.826, 0.025, -0.087, -0.011, -0.004, 
        0.3, -1.293, 0.026, -0.061, 0.016, -0.001, -0.273, -1.48, 
        0.011, -0.045, 0.014, -0.003, 11.858, -1.931, 0.015, -0.08, 
        -0.014, -0.002, 12.624), ci.ub = c(-1.071, 0.045, 0.019, 
        0.022, 0.007, 7.305, -0.775, 0.038, 0.012, 0.035, 0.007, 
        6.613, -0.816, 0.029, 0.051, 0.039, 0.008, 13.569, -1.056, 
        0.04, 0.038, 0.027, 0.01, 14.375), Adjusted = structure(c(1L, 
        1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
        2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Adjusted", "Unadjusted"
        ), class = "factor"), Dataset = structure(c(1L, 1L, 1L, 1L, 
        1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
        2L, 2L, 2L, 2L, 2L), .Label = c("a", "b"), class = "factor")), .Names = c("term", 
    "coef", "ci.lb", "ci.ub", "Adjusted", "Dataset"), class = c("tbl_df", 
    "tbl", "data.frame"), row.names = c(NA, -24L))

ggplot(data = tb5,aes(x=term,y=coef,color=Dataset))+geom_point()+
  facet_grid(facets = ~Adjusted)+
  geom_jitter(height = .8)
库(ggplot2)

tb5使用
geom_point
geom_jitter
,而不是两者都使用,或者您正在双击每个点。Thx。但愿我两天前问过:-)看起来你想要的是
ggplot(data=tb5,aes(x=term,y=coef,color=Dataset))+geom_point(position=position\u dodge(0.2))+facet\u grid(facets=~调整)
。如果没有回避,不同的
数据集
s但相同的
术语
的点如果具有相同的y值,则会相互重叠绘制。