Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clipping in geom_abline() #6109

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6086.

Briefly, also clips the line to y-limits.

Reprex from #6086 (comment):

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note the purple segment at the top is now gone. It should be gone because coord_polar() has 0 y-axis expansions, so it was actually out-of-bounds before.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Visually identical, as is the flipped one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Could geom_abline always be clipped to panel in both x and y directions?
1 participant