Skip to content

strange problem under a fixed aspect coordinates #175

@ghost

Description

Thanks for developing such a nice package.

There's a very strange problem under a fixed aspect coordinates, and here's a simple example to reproduce the problem.

df1 <- data.frame(x = 1:10, y = rnorm(10))
df2 <- expand.grid(x = 1:10, y = 1:10)
df2$value <- rnorm(100)
df3 <- data.frame(x = runif(10, 0, 3), y = 1:10)

library(ggplot2)
library(patchwork)
p1 <- ggplot(df1, aes(x, y)) +
  geom_point() +
  scale_x_continuous(limits = c(0.5, 10.5), expand = c(0, 0)) +
  coord_fixed()

p2 <- ggplot(df2, aes(x, y, fill = value)) +
  geom_tile() +
  scale_x_continuous(limits = c(0.5, 10.5), expand = c(0, 0)) +
  scale_y_continuous(limits = c(0.5, 10.5), expand = c(0, 0)) +
  coord_fixed()

p3 <- ggplot(df3, aes(x, y)) +
  geom_col() +
  scale_x_reverse() +
  scale_y_continuous(limits = c(0.5, 10.5), expand = c(0, 0)) +
  coord_fixed()
plot_spacer() + p1 + p3 + p2 +
  plot_layout(nrow = 2, byrow = TRUE, guides = "collect")

unnamed-chunk-1-1

p1 + plot_spacer() + p2 + p3 +
  plot_layout(nrow = 2, byrow = TRUE, guides = "collect")

unnamed-chunk-1-2

p3 + p2 + plot_spacer() + p1 +
  plot_layout(nrow = 2, byrow = TRUE, guides = "collect")

unnamed-chunk-1-3

p2 + p3 + p1 + plot_spacer() +
  plot_layout(nrow = 2, byrow = TRUE, guides = "collect")

unnamed-chunk-1-4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions