3D Pie

Authors

[Editor] Hu Zheng;

[Contributors]

Modified

2026-01-17

Note

Hiplot website

This page is the tutorial for source code version of the Hiplot 3D Pie plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:

https://hiplot.cn/basic/pie-3d?lang=en

The 3D pie chart is a pie chart that has a 3D appearance.

Setup

  • System Requirements: Cross-platform (Linux/MacOS/Windows)

  • Programming language: R

  • Dependent packages: data.table; jsonlite; plotrix; ggplotify

# Install packages
if (!requireNamespace("data.table", quietly = TRUE)) {
  install.packages("data.table")
}
if (!requireNamespace("jsonlite", quietly = TRUE)) {
  install.packages("jsonlite")
}
if (!requireNamespace("plotrix", quietly = TRUE)) {
  install.packages("plotrix")
}
if (!requireNamespace("ggplotify", quietly = TRUE)) {
  install.packages("ggplotify")
}

# Load packages
library(data.table)
library(jsonlite)
library(plotrix)
library(ggplotify)
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
 ggplotify  * 0.1.3   2025-09-20 [1] RSPM
 jsonlite   * 2.0.0   2025-03-27 [1] RSPM
 plotrix    * 3.8-13  2025-11-15 [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 different groups and their data.

# Load data
data <- data.table::fread(jsonlite::read_json("https://hiplot.cn/ui/basic/pie-3d/data.json")$exampleData$textarea[[1]])
data <- as.data.frame(data)

# Convert data structure
colnames(data) <- c("Group", "Value")
data$Value <- as.numeric(data$Value)
data <- data[data$Value != 0,]

# View data
head(data)
   Group Value
1 Group1    13
2 Group2    34
3 Group3    21
4 Group4    43

Visualization

# 3D Pie
pie3D(data$Value, radius = 0.8, height = 0.05, theta = 0.8,
      labels = paste(data$Group, "\n(n=", data$Value, ", ",
                     round(data$Value / sum(data$Value) * 100, 2), "%)",
                     sep = ""),
      explode = 0.1, main = "", labelcex = 1, shade = 0.4, labelcol = "black",
      col = c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF"))
FigureΒ 1: 3D Pie

The figure shows more aesthetically the number of samples in groups 1 to 4 and the proportion corresponding to the number of samples in the 3D form. The number of samples in one group is 13, accounting for 11.71%; the number of samples in two groups is 34, accounting for 30.63%; the number of samples in three groups is 21, accounting for 18.92%; and the number of samples in four groups is 43, accounting for 38.74%.