Skip to content

Datapoints disapearing when lims() conflicts with position_dodge() #5148

@DanChaltiel

Description

@DanChaltiel

Hi,

It is a bit unexpected that lims() consider the actual position of each point (after considering the dodge) and not its original position.

This makes some points disappear while the real value is within the limits.

For instance, consider:

library(tidyverse)


dat=tibble(x=rep(0:4, 2), y=rep(0:4, 2), gp=rep(c("A","B"), each=5))
p = ggplot(dat, aes(x,y, color=gp)) + geom_point(position=position_dodge(0.5))
p

p + xlim(0,NA)
#> Warning: Removed 1 rows containing missing values (`geom_point()`).

Created on 2023-01-12 with reprex v2.0.2

I cannot see how this can be a wanted behavior, as dodging is only about visualization and not about showing actual data. However, if it is, maybe this would be worth documenting, for instance in ?position_dodge and/or in ?lims.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions