Skip to content

Coord_flip() has some issues when interacting with panel.grid.major and panel.grid.minor #6293

Closed
@oskard95

Description

@oskard95

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorcoord 🗺️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions