# Install packages
if (!requireNamespace("ggpol", quietly = TRUE)) {
install.packages("ggpol")
}if (!requireNamespace("ggplot2", quietly = TRUE)) {
install.packages("ggplot2")
}
# Load packages
library(ggpol)
library(ggplot2)
Parliament
Hiplot website
This page is the tutorial for source code version of the Hiplot Parliament
plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:
The parliamentary chart is a data processing method that looks like a parliamentary seat, with points representing a data set to show the share ratio of each group more flexibly.
Setup
System Requirements: Cross-platform (Linux/MacOS/Windows)
Programming language: R
Dependent packages:
ggpol
;ggplot2
Data Preparation
The loaded data are groups and their corresponding values.
# Load data
<- read.delim("files/Hiplot/134-parliament-data.txt", header = T)
data
# View data
head(data)
group value
1 G1 200
2 G2 46
3 G3 92
4 G4 80
5 G5 150
Visualization
# Parliament
<- ggplot(data) +
p geom_parliament(alpha = 1, aes(seats = value, fill = group), color = "black") +
coord_fixed() +
scale_fill_discrete(name = "group", labels = unique(data$group)) +
scale_fill_manual(values = c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF",
"#F39B7FFF")) +
ggtitle("Parliament Plot") +
theme_void() +
theme(legend.position = "bottom",
plot.title = element_text(hjust = 0.5))
p

Different colors represent different groups, and each dot represents one data point. Itβs a semicircle of points, the smallest fraction of which can be represented by a single point in a parliamentary diagram.