davidgohel / ggiraph

make 'ggplot' graphics interactive

Home Page:https://davidgohel.github.io/ggiraph

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specifying svg_width/height changes legend pattern

carlganz opened this issue · comments

library(ggplot2)
library(ggpattern)
library(ggiraph)

df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))

p <- ggplot(df, aes(trt, outcome, pattern = trt, fill = trt)) +
  geom_col_interactive() + 
  geom_col_pattern(
    colour                   = 'black', 
    pattern_density          = 0.5, 
    pattern_key_scale_factor = 1.11
  ) +
  theme_bw(18) +
  labs(title = "ggpattern::geom_col_pattern()") + 
  # theme(legend.position = 'none') +  
  coord_fixed(ratio = 1/2)

p
girafe(ggobj=p)
girafe(ggobj=p, 
       width_svg = 8,
       height_svg = 4
       )

Pattern is included in legend for p and girafe(ggobj=p) but not when the extra parameters are included.

Fixed by setting pattern_key_scale_factor