Skip to content

position_dogev for points  #5809

@smouksassi

Description

@smouksassi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions