-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
ggstance has been deprecated and recently was removed from CRAN @lionel- kindly offered that he will make a last ditch edits to re instate it on CRAN but it is bound to disappear.
One of the last things that we still cannot do in ggplot2 is being able to dodge point vertically for various reasons:
the geom_point has no orientation that can force the position to work in the alternative direction
is there a way to enable vertical dodging for points ? or to force geom_point to have flipped aes ?
https://github.com/tidyverse/ggplot2/blob/main/R/position-dodge.R#L97
library(ggplot2)
library(ggstance)
#>
#> Attaching package: 'ggstance'
#> The following objects are masked from 'package:ggplot2':
#>
#> geom_errorbarh, GeomErrorbarh
library(patchwork)
df <- data.frame(
trt = c(1,1,2,2),
resp = c(1, 5, 3, 4),
group = factor(c(1, 2, 1, 2)),
upper = c(1.1, 5.3, 3.3, 4.2),
lower = c(0.8, 4.6, 2.4, 3.6)
)
ggplot(df, aes( resp,trt, colour = group))+
geom_linerange(aes(xmin = lower, xmax = upper),
position = position_dodge(width=0.2),orientation ="y")+
geom_point(aes(group=interaction(group,trt)),position = position_dodge(width=0.2)) |
ggplot(df, aes( resp,trt, colour = group))+
geom_linerange(aes(xmin = lower, xmax = upper),
position = position_dodge(width=0.2),orientation ="y")+
geom_point(aes(group=interaction(group,trt)),position = position_dodgev(height=0.2))
Created on 2024-03-26 with reprex v2.1.0