I have the following dataset where I am visualizing a range comparison for different features between two model types in ggplot2
with geom_segment
.
test <- data.frame("var" = c("apple", "apple", "banana", "banana", "pear", "pear"),
"model" = c("mod1", "mod2", "mod1", "mod2", "mod1", "mod2"),
"lower" = c(1, 3, 2, 5, 6, 2),
"upper" = c(7, 5, 7, 7, 10, 6))
Below is the code snippet I am currently using for the visual, as well as the output. But right now the two different model
types are overlayed on the plot, and I would like to have them "dodged" so that they are next to each other instead of overlayed. Any ideas?
library(ggplot2)
ggplot(test) +
geom_segment(aes(x=var,
xend=var,
y=lower,
yend=upper,
colour=model,
group=model), size=8) +
theme_bw()