Last active
August 29, 2015 14:17
-
-
Save jalapic/791d63669cabdd36a79f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Waffle Charts | |
#install waffle & rcdimple | |
devtools::install_github("timelyportfolio/rcdimple") # only for htmlwidget functionality | |
devtools::install_github("hrbrmstr/waffle") | |
library(waffle) | |
#data | |
ids <- c(1520, 656, 182, 35, 187, 193, 21, 56, 61, 26, 28) | |
#colors | |
mycolors <- c("orange4", "orange2", "orange", "yellow", "yellow3", "greenyellow", "darkolivegreen2", "darkolivegreen4", "darkseagreen3", | |
"darkturquoise", "dodgerblue", "blue4") | |
#generate initial plot | |
p <- waffle(ids/10, rows=8, colors=rev(mycolors)) | |
# add title and footer | |
p + | |
ggtitle("Number of interactions initiated by dominance rank") + | |
xlab("Each block represents 10 initiated interactions") + | |
theme( | |
plot.title = element_text(hjust=0,vjust=1, size=rel(1.6)), | |
axis.title.x = element_text(face="italic", hjust=0.95,vjust=1, size=rel(1))) | |
# notes - see comments | |
### Second Example. | |
parts <- c(`Un-breached\nUS Population`=(318-11-79), `Premera`=11, `Anthem`=79) | |
p2 <- waffle(parts/10, rows=3, colors=c("#969696", "#1879bf", "#009bda")) | |
p2 + | |
ggtitle("Health records breaches as fraction of US Population") + | |
xlab("(One square == 10m ppl)") + | |
theme( | |
plot.title = element_text(hjust=0,vjust=1, size=rel(1.6)), | |
axis.title.x = element_text(face="italic", hjust=0.95,vjust=1, size=rel(1))) | |
EDIT: | |
#from example 1.. | |
### as_rcdimple test | |
p1 <- p + | |
ggtitle("Number of interactions initiated by dominance rank") + | |
xlab("Each block represents 10 initiated interactions") + | |
theme( | |
plot.title = element_text(hjust=0,vjust=1, size=rel(1.6)), | |
axis.title.x = element_text(face="italic", hjust=0.95,vjust=1, size=rel(1))) | |
as_rcdimple(p1) # something funky going on ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's great - I will play around more with it. Interested to know if it's possible to further customize the hover text?