Closed teunbrand closed 2 months ago
In the example below, ranges 1, 2, 3 all overlap and hence should get the same overlap identifier from find_x_overlaps(). However, range 3 is counted separately, despite having 100% overlap with range 1.
find_x_overlaps()
library(ggplot2) f <- function(x, xend) ggplot2:::find_x_overlaps(data.frame(xmin = x, xmax = xend)) df <- data.frame( xmin = c(1, 2, 3, 5), xmax = c(4, 3, 4, 6), group = factor(1:4) ) ggplot(df, aes(x = xmin, xend = xmax, y = group)) + geom_segment(aes(colour = factor(f(xmin, xmax))))
Consequentially, position_dodge2() does not actually dodge range 3 from 1 & 2:
position_dodge2()
ggplot(df, aes(xmin = xmin, xmax = xmax)) + geom_rect(aes(ymin = 0, ymax = 1, fill = group), alpha = 0.75, position = position_dodge2())
Created on 2024-06-07 with reprex v2.1.0
In the example below, ranges 1, 2, 3 all overlap and hence should get the same overlap identifier from
find_x_overlaps()
. However, range 3 is counted separately, despite having 100% overlap with range 1.Consequentially,
position_dodge2()
does not actually dodge range 3 from 1 & 2:Created on 2024-06-07 with reprex v2.1.0