0

I am trying to reproduce a simple waffle graph like this from Tableau with R: enter image description here

I'm not sure if is doable in waffle package, however I would really appreciate any help on two cases:

  • Is there any way to color fill the waffle chart row-wise (like Tableau example) not column-wise?
  • Is it possible to add label percent (24%) to the Waffle chart?

Here is my try so far :

 library(waffle)  

 # dummy sample 
 basedata <- c('User'=24, 'Not User'=  76)

 # Waffle chart
 waffle(
   basedata,
   rows = 10 ,
   colors =  c("#636363", "#fee8c8"),
   xlab = "1 square == 1%"
 ) +
   ggtitle("Some tilte") +
   theme(
     plot.title = element_text(hjust = 0.5, size = 27, face = "bold"),
     legend.text = element_text(size = 15),
     legend.position = "bottom"
   )

Which will return this enter image description here

DanG
  • 689
  • 1
  • 16
  • 39

1 Answers1

2

This should do it:

# dummy sample 
basedata <- c('User'=24, 'Not User'=  76)

# Waffle chart
waffle(
  basedata,
  rows = 10 ,
  colors =  c("#636363", "#fee8c8"),
  xlab = "1 square == 1%",
  flip = TRUE
) +
  ggtitle("Some tilte") +
  theme(
    plot.title = element_text(hjust = 0.5, size = 27, face = "bold"),
    legend.text = element_text(size = 15),
    legend.position = "bottom"
  ) +
  annotate("text", x = 4, y = 5, label = paste(basedata[1], "%"))

enter image description here

Dhiraj
  • 1,650
  • 1
  • 18
  • 44