# Install packages
if (!requireNamespace("waffle", quietly = TRUE)) {
install.packages("waffle")
}
# Load packages
library(waffle)
Waffle Plot
Note
Hiplot website
This page is the tutorial for source code version of the Hiplot Waffle Plot
plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:
Setup
System Requirements: Cross-platform (Linux/MacOS/Windows)
Programming language: R
Dependent packages:
waffle
Data Preparation
# Load data
<- read.delim("files/Hiplot/184-waffle-data.txt", header = T)
data
# convert data structure
<- data[,2]
parts
# View data
head(data)
label value
1 Un-breached US Population 230
2 Premera 11
3 Anthem 79
Visualization
# Waffle Plot
<- waffle(parts, rows = 8, size = 1, legend_pos = "right") +
p ggtitle("Waffle Plot") +
scale_fill_manual(values = c("#e04d39","#5bbad6","#1e9f86")) +
theme(text = element_text(family = "Arial"),
plot.title = element_text(size = 12,hjust = 0.5),
axis.title = element_text(size = 12),
axis.text = element_text(size = 10),
axis.text.x = element_text(angle = 0, hjust = 0.5,vjust = 1),
legend.position = "right",
legend.direction = "vertical",
legend.title = element_text(size = 10),
legend.text = element_text(size = 10))
p
