Fan Plot

Authors

[Editor] Hu Zheng;

[Contributors]

The pie chart is a statistical chart designed to clearly show the percentage of each data group by the size of the pie.

Setup

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

  • Programming language: R

  • Dependent packages: plotrix; ggplotify

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

# Load packages
library(plotrix)
library(ggplotify)

Data Preparation

The loaded data are different groups and their data.

# Load data
data <- read.delim("files/Hiplot/054-fan-data.txt", header = T)

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

Visualization

# Fan Plot
p <- as.ggplot(function() {
  fan.plot(data[, 2], main = "", labels = as.character(data[, 1]),
           col = c("#E64B35FF","#4DBBD5FF","#00A087FF","#3C5488FF"))
  })

p
FigureΒ 1: Fan Plot

Different colors represent different groups and different areas represent data and proportion.