Skip to content

point is misplaced if width = 0 is used in position_dodge2 with geom_point #4327

@joelgautschi

Description

@joelgautschi

If position_dodge2(width = 0) is used with the position argument in geom_point() (one?) is wrongly placed horizontally (i. e., wrong 'column' for discrete values). This only seems to be an issue if width = 0.
If position_dodge2() is not intended to be used with geom_point() a warning would be helpful.

library(tidyverse)

df <- tribble(~dimension, ~group, ~value,
              "dim 1", "A", 0.6,
              "dim 1", "B", 0.7,
              "dim 2", "A", 0.4,
              "dim 2", "B", 0.5)

plot <- ggplot(data = df,
               mapping = aes(x = dimension,
                             y = value,
                             color = group))  

# point in wrong column (point of 'dim 1' 'B' appears in column of 'dim 2'
plot +  geom_point(
             position = position_dodge2(width = 0))

# correct column
plot + geom_point(
  position = position_dodge2(width = 0.5))

Created on 2021-01-26 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviormessagesrequests for improvements to error, warning, or feedback messagespositions 🥇

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions