ggfx icon indicating copy to clipboard operation
ggfx copied to clipboard

Error with custom filter and theme_void()

Open nrennie opened this issue 2 years ago • 1 comments

Adding theme_void() to a plot with a custom filter using Magick results in an error. When testing with other theme functions such as theme_minimal() or theme_classic() it works fine. Small reprex based on the example in the documentation:

library(ggplot2)
library(ggfx)

# Example from documentation
implode <- function(x, factor = 0.5) {
  vp <- magick::image_read(get_viewport_area(x))
  vp <- magick::image_implode(vp, factor = factor)
  set_viewport_area(x, as.raster(vp, native = TRUE))
}

ggplot(mtcars, aes(x = factor(gear), y = disp)) +
  with_custom(
    geom_boxplot(aes(fill = as.factor(gear))),
    filter = implode
  ) 


# Adding theme_void() returns an error
# Other theme_*() functions don't seem to have this issue
ggplot(mtcars, aes(x = factor(gear), y = disp)) +
  with_custom(
    geom_boxplot(aes(fill = as.factor(gear))),
    filter = implode
  ) +
  theme_void()
#> Error in .subset(raster, index): only 0's may be mixed with negative subscripts

Created on 2023-08-25 with reprex v2.0.2

nrennie avatar Aug 25 '23 19:08 nrennie