trevorld / ggpattern

ggplot geoms with pattern fills
https://trevorldavis.com/R/ggpattern/dev/
Other
359 stars 18 forks source link

geom_map_pattern() error #27

Closed baifengbai closed 3 years ago

baifengbai commented 3 years ago

while running


library(maps)

crimes <- data.frame(state = tolower(rownames(USArrests)), USArrests)
crimesm <- reshape2::melt(crimes, id = 1)

states_map <- map_data("state")

p <- ggplot(crimes, aes(map_id = state)) +
    geom_map_pattern(
      map = states_map,
      aes(
        pattern_type = state
      ),
      pattern              = 'magick',
      pattern_fill         = 'black',
      pattern_aspect_ratio = 1.75,
      fill                 = 'white',
      colour               = 'black',
    ) +
    expand_limits(x = states_map$long, y = states_map$lat) +
    coord_map() +
    theme_bw(18) +
    labs(title = "ggpattern::geom_map_pattern()") +
  labs(
    title = "ggpattern::geom_map_pattern()",
    subtitle = "pattern = 'magick'"
  ) +
    scale_pattern_type_discrete(choices = ggpattern::magick_pattern_names) +
    theme(legend.position = 'none')

p

got


Error in png(png_file, width = width, height = height) : 
  invalid quartz() device size
In addition: Warning messages:
1: create_magick_pattern_img(): zero size 
2: In FALSE :
  create_pattern_array(): Expecting a numeric RGBA array with dim = c(1, 0, 4) but instead got a "array" of type double with dimensions c(1L, 10L, 4L)