# Install packages
if (!requireNamespace("data.table", quietly = TRUE)) {
install.packages("data.table")
}
if (!requireNamespace("jsonlite", quietly = TRUE)) {
install.packages("jsonlite")
}
if (!requireNamespace("ggpol", quietly = TRUE)) {
install.packages("https://cran.r-project.org/src/contrib/Archive/ggpol/ggpol_0.0.7.tar.gz")
}
if (!requireNamespace("ggplot2", quietly = TRUE)) {
install.packages("ggplot2")
}
# Load packages
library(data.table)
library(jsonlite)
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:
data.table;jsonlite;ggpol;ggplot2
sessioninfo::session_info("attached")β Session info βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
setting value
version R version 4.5.2 (2025-10-31)
os Ubuntu 24.04.3 LTS
system x86_64, linux-gnu
ui X11
language (EN)
collate C.UTF-8
ctype C.UTF-8
tz UTC
date 2026-01-17
pandoc 3.1.3 @ /usr/bin/ (via rmarkdown)
quarto 1.8.27 @ /usr/local/bin/quarto
β Packages βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
package * version date (UTC) lib source
data.table * 1.18.0 2025-12-24 [1] RSPM
ggplot2 * 4.0.1 2025-11-14 [1] RSPM
ggpol * 0.0.7 2025-12-23 [1] Github (erocoar/ggpol@0844060)
jsonlite * 2.0.0 2025-03-27 [1] RSPM
[1] /home/runner/work/_temp/Library
[2] /opt/R/4.5.2/lib/R/site-library
[3] /opt/R/4.5.2/lib/R/library
* ββ Packages attached to the search path.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Data Preparation
The loaded data are groups and their corresponding values.
# Load data
data <- data.table::fread(jsonlite::read_json("https://hiplot.cn/ui/basic/parliament/data.json")$exampleData$textarea[[1]])
data <- as.data.frame(data)
# View data
head(data) group value
1 G1 200
2 G2 46
3 G3 92
4 G4 80
5 G5 150
Visualization
# Parliament
p <- ggplot(data) +
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.
