如何在R中的y轴上有选择地放置重叠点

时间:2019-04-10 22:15:14

标签: r ggplot2 data-visualization

我想知道如何使分类变量在图中以一定顺序出现?现在,y = YZ处的绿点为(1,1),但y = YZ处的绿点更像(1,2.2)。我想确切地在(1,YZ)上。

如何指定我的点的确切坐标?

任何帮助将不胜感激!


 x<- c("1","1","1","1","1")

    y <- c("XY","XY","XY","YZ","YZ")

    z <- c("Treatment 1","Treatment 2","Treatment 3","Treatment 1","Treatment 2")

    data<- data.frame (x,y,z)

    ggplot(data=data,aes (x=y, y=x, color = z)) + 
    coord_flip() +
    geom_point(pch = 16, size = 3, position = position_dodge(width = 0.2)) +
    xlab("ID") +
    ylab("Time") + 
    theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust=0.5))

enter image description here

0 个答案:

没有答案