When I use geom_plot()
with position_dodge()
for the position
argument, I get a warning position_dodge requires non-overlapping x intervals
if I use a negative value for width
in position_dodge()
.
my intention for using a negative width value was to display the grouping variable in reversed order.
is there a way to avoid this warning (maybe a different approach to reoder the grouping variable?)?
see the following reprex
library(tidyverse)
df <- tribble(~dimension, ~group, ~value,
"dim 1", "A", 0.5,
"dim 1", "B", 0.75,
"dim 2", "A", 0.4,
"dim 2", "B", 0.4)
plot <- ggplot(data = df,
mapping = aes(x = dimension,
y = value,
color = group))
# no warning
plot +
geom_point(size = 2,
position = position_dodge(width = 0.5))
# warning
plot +
geom_point(size = 2,
position = position_dodge(width = -0.5))
#> Warning: position_dodge requires non-overlapping x intervals
Created on 2021-01-15 by the reprex package (v0.3.0)