Search code examples
rggplot2waffle-chart

Waffle plot with decimal numbers


When you have values <1 in a waffle plot they won't display.

library(waffle)
wp<-waffle(c(10,25,25,1,0.05,0.5,30,7.5,0.95),
           rows=10,
           colors=c("#CC0000", "#006600", "#669999", "#00CCCC", 
                    "#660099", "#CC0066", "#FF9999", "#FF9900", "black"))

enter image description here

Is there a way using waffle or ggplot to fill in the remaining boxes with their proportional value? e.g. multiple colours per cell ?


Solution

  • That is kind of the point. As @camille said, it is kind of the point of a waffle plot to have 1 element per full observation.

    What you (or anyone else wanting a similar result) could do, however, is to reshape the data slightly to reflect those small observations in their own "Others" category:

    parts <- c("A" = 10, "B" = 25, "C" = 25, "D" = 1, "G" = 30, "H" = 7.5, 
           "Others" = 0.95 + 0.05 + 0.5)
    waffle(parts,
           rows=10,
           colors=c("#CC0000", "#006600", "#669999", "#00CCCC", 
                    "#FF9999", "#FF9900", "blue"))
    

    Result plot