hrbrmstr / waffle

:maple_leaf: Make waffle (square pie) charts in R
770 stars 95 forks source link

Issue with ggplotly #78

Open AlejandroAyllon opened 3 years ago

AlejandroAyllon commented 3 years ago

When I try to use ggplotly in order to show tooltips I get the following error message: Error: margins must be length 1 or 4

It can be solved if you comment line 281 in original function code (https://github.com/hrbrmstr/waffle/blob/master/R/waffle.R) and rename the function:

waffle2 <- function(...){
...
# gg <- gg + theme(panel.spacing = unit(c(0, 0, 0, 0), "null"))
...
}

I have tested with the following example and it works:

data <- c('Yes' = 24, 'No' = 76)
g1 <- waffle2(
  data,
  rows = 10,
  colors =  c("#4E79A7", "#A0CBE8"),
  flip = TRUE
  ) +
  ggtitle("Waffle") +
  theme(
    plot.title = element_text(hjust = 0.5, size = 27, face = "bold"),
    legend.position = "none",
  )
ggplotly(g1)

P.S. I will try to change the tooltip.

rempsyc commented 1 year ago

Thanks, I was looking for a solution to this