The good old Kanji Talk icon was obtained from this website.
http://www.kanshin.com/keyword/9337
Paintbrush was used to paint the Sun red, and convert file to PNG format.
http://sourceforge.net/projects/paintbrush/?source=recommended
Actual icon before import
Look how small these 32 x 32 icons are these days!
png package was used to import the png file as an array.
32 x 32 matrices for the R, G, B, and alpha layers.
library(png)
fuji <- png::readPNG("~/statistics/fun/KajiTalkColored.png")
Add up RGB to create one matrix
fuji <- apply(X = fuji[,,1:3], MARGIN = c(1,2), FUN = sum)
Melt to create a data frame
library(reshape2)
fuji.melt <- melt(fuji)
Change numbers to corresponding colors
library(car)
fuji.melt$value <- car::recode(fuji.melt$value, '"0" = "black"; "1" = "red"; "3" = "white"')
fuji.melt$value <- factor(fuji.melt$value)
Map variables
library(ggplot2)
p <- ggplot(fuji.melt, aes(x = Var1, y = Var2, fill = value))
Initial plot
p + geom_tile()
Final plot
p + geom_tile() +
coord_flip() +
scale_x_continuous(trans = "reverse", expand = c(0,0)) +
scale_y_continuous(expand = c(0,0)) +
scale_fill_identity() +
labs(title = "A Happy New Year", x = "", y = "") +
theme(title = element_text(size = 18))