Skip to content

geom_vline() and geom_hline() affect x and y scales #6768

@dboutwell3

Description

@dboutwell3

In prior versions of ggplot2, geom_vline and geom_hline did not affect the x and y scales, which was/is still currently the documented behavior. However, as of 4.0.1 (and possibly earlier - I have not explicitly tested 4.0.0) these functions do affect the x and y scales. Note that geom_abline continues to behave as documented, e.g. it continues to not affect the x and y scales.

Here is the code to reproduce the bug:

library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
p + geom_vline(xintercept = 5)
p + geom_vline(xintercept = 10) # affects scale
p + geom_hline(yintercept = 30)
p + geom_hline(yintercept = 60) # affects scale
p + geom_abline(slope = 1, intercept = 10)
p + geom_abline(slope = 1, intercept = 50) # does not affect scale

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