ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

Clipping in `geom_abline()`

Open teunbrand opened this issue 1 year ago • 0 comments

This PR aims to fix #6086.

Briefly, also clips the line to y-limits.

Reprex from https://github.com/tidyverse/ggplot2/issues/6086#issuecomment-2334851231:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

ggplot() +
  geom_abline(colour = "blue", slope = 0.1) +
  geom_abline(colour = "red", slope = 6) +
  coord_cartesian(clip = "off") +
  xlim(-2, 2) + ylim(-2, 2) +
  theme(plot.margin = margin(50, 50, 50, 50))

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

teunbrand avatar Sep 17 '24 06:09 teunbrand