patchwork icon indicating copy to clipboard operation
patchwork copied to clipboard

Won't render plots with `ggforce::facet_zoom`

Open geryan opened this issue 6 years ago • 1 comments

Thanks for making this great free software available.

Something wack going on here where the plot area won't appear, just axes legends etc.

library(ggplot2)
library(ggforce)
library(patchwork)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union

zoomlims <- data.frame(
  cyl = c(4, 6, 8),
  lower = c(27, 18, 13),
  upper =c(32, 21, 17)
)

p1 <- ggplot(mtcars %>% filter(cyl == 4)) +
  geom_boxplot(
    aes(
      x = factor(gear),
      y = mpg,
      fill = factor(gear)
    )
  ) +
  facet_zoom(
    ylim = c(zoomlims$lower[1], zoomlims$upper[1]),
    zoom.size = 1
  )

p1



p2 <- ggplot(mtcars %>% filter(cyl == 6)) +
  geom_boxplot(
    aes(
      x = factor(gear),
      y = mpg,
      fill = factor(gear)
    )
  ) +
  facet_zoom(
    ylim = c(zoomlims$lower[2], zoomlims$upper[2]),
    zoom.size = 1
  )

p2


p1+p2

Created on 2020-02-14 by the reprex package (v0.3.0)

geryan avatar Feb 14 '20 01:02 geryan

just came across the same issue, the unzoomed plot is fine, the zoom one gives only axes.

abusjahn avatar Feb 25 '21 20:02 abusjahn