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

Coord flip grid #6319

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

Coord flip grid #6319

wants to merge 3 commits into from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #6293.

Briefly, the flip coord transform swaps the 'x' and 'y' names which makes sense for layers, but not so much the panel grid as it already recieves the variables in flipped form. The solution is to flip again before going into coord transform.

The reprex from the issue, notice the ticks and grid lining up again:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2
x <- -1:10
y <- -1:10
dati <- as.data.frame(x,y)

ggplot(dati, aes(x = x, y = y)) +
  geom_point() +
  scale_x_continuous(breaks = seq(-15, 15, by = 3), 
                     limits = c(-15,15)) +
  coord_flip()+
  theme(panel.grid.major = element_line(color = "blue"),
        panel.grid.minor = element_line(color = "red"))

Created on 2025-02-05 with reprex v2.1.1

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.

Coord_flip() has some issues when interacting with panel.grid.major and panel.grid.minor
1 participant