Skip to content

Dots misaligned in geom_dotplot #4614

Closed
@Marijn1009

Description

@Marijn1009

Hello!
I've ran into a problem where the dots of geom_dotplot are not aligned correctly. The problem was described here years ago, but it seems to still be here (and I couldn't find any issue about it so I assume nobody ever filed one). The link also provides a possible solution but no one seems to have a clue if this solution affects anything elsewhere.

library(ggplot2)

data <- data.frame(x = rep(seq(2018, 2021, 1), 15), 
                   y = sample(seq(3, 5, .125), 60, 
                              replace = T))

ggplot(data, aes(factor(x), y)) +
  geom_dotplot(binaxis = "y", stackdir = "center", stackratio = 1)
#> Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.

ggplot(data, aes(factor(x), y)) +
  geom_dotplot(binaxis = "y", stackdir = "center", stackratio = 2) #points shifted to left
#> Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.

ggplot(data, aes(factor(x), y)) +
  geom_dotplot(binaxis = "y", stackdir = "center", stackratio = 0.5) #points shifted to right
#> Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.

Created on 2021-09-14 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorlayers 📈

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions