I have a ggplot where some of the points are overlapping with a few others. I was wondering if there is a way to put the points one above the other. In my case, there are 2 points at most overlapping.
x=c(1,1,2,3,4,4)
y=c('a1','a1','a2','a3','a4','a4')
type = c('A','B','C','A','B','C')
data = as.data.frame(cbind(x,y,type))
ggplot() + geom_point(data = data, aes(x=x,y=y, color = type, fill = type), size = 2, shape = 25)
Here we see that for point x=1 and y=a1
the type A
is sitting beneath type B
but I ideally want Type B
to be shifted vertically by a bit.
If I use jitter, every thing gets displaced, including the points that don't have an overlap.