Skip to content

Could geom_abline always be clipped to panel in both x and y directions? #6086

Closed
@davidhodge931

Description

@davidhodge931

Following on from #6081

This would be helpful, as abline is always needed in the panel - and then you would have the flexibility to adjust the scale and coord settings without adversely affecting the abline.

Currently it does on the x, but not on the y.

library(tidyverse)
library(palmerpenguins)

ggplot() +
  geom_abline(colour = "blue", slope = 0.1) +
  geom_abline(colour = "red", slope = 6) +
  scale_x_continuous(limits = c(-2, 2), oob = scales::oob_keep, expand = c(0, 0)) +
  scale_y_continuous(limits = c(-2, 2), oob = scales::oob_keep, expand = c(0, 0)) +
  coord_cartesian(clip = "off") +
  theme(plot.margin = margin(50,50,50,50))

Created on 2024-09-07 with reprex v2.1.1

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