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() has some issues when interacting with panel.grid.major and panel.grid.minor #6293

Open
oskard95 opened this issue Jan 22, 2025 · 1 comment
Labels
bug an unexpected problem or unintended behavior coord 🗺️

Comments

@oskard95
Copy link

oskard95 commented Jan 22, 2025

I found a problem with panel.grid and coord_flip in the 3.5 update. It seems that the panel grids only produce on observed values but not on axis values after coord_flipping.

In the code below, when you leave out coord_flip - the panel.grid lines will be normal - when you include coord_flip() the X axis lines (flipped to Y axis) only show on values of X.

If you include scale_y_contininious - the lines appear again.

Below, leave is some simple code to reproduce the bug:

library(tidyverse)
x <- -1:10
y <- -1:10
dati <- as.data.frame(x,y)


dati %>% 
  ggplot(aes(x = x, y = y)) +
  geom_point() +
  scale_x_continuous(breaks = seq(-15, 15, by = 3), 
                     limits = c(-15,15)) +
  # scale_y_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"))

Image
This is without coord_flip - as is in the code example.

Image

And this is when i include coord_flip exact same code - just removed the comment in front of coord_flip. If the scale_y_contininious is left in there, it fixes itself but I think this is not supposed to be needed.

I think this is related to the 3.5 update as its been confirmed by others to work as intended in previous versions. I understand the function was superseded but I think this is unintended behaviour

@teunbrand
Copy link
Collaborator

Thanks for the report! I can reproduce the issue and agree that it looks like a bug.

@teunbrand teunbrand added coord 🗺️ bug an unexpected problem or unintended behavior labels Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior coord 🗺️
Projects
None yet
Development

No branches or pull requests

2 participants