Chart type
Sunburst

Definition
A sunburst diagram displays a hierarchical structure. The origin of the organization is represented by the center of the circle, and each level of the organization by an aditional ring. The last level (leaves) are located at the extreme outer part of the circle. It is very similar to a treemap, except it uses a radial layout.
A sunburst diagram can be used in 2 situations:
- Part of a whole - the sunburst diagram can be used to represent a part of a whole. In this case, the center of the circle represents the whole, and the outer part represents the parts. The following example shows the world population of 250 countries.
- Flows - the sunburst diagram can also be used to represent flows. In this case, the center of the circle represents the origin of the flow, and the outer part represents the destination. The following example shows the professional state evolution of a set of people.
Part of a whole
Here is an example describing the world population of 250 countries. The world is divided in continent (group), continent are divided in regions (subgroup), and regions are divided in countries. In this tree structure, countries are considered as leaves: they are at the end of the branches. They are thus represented at the outer part of the circle.
Show codeHide code
# libraries
library(tidyverse)
library(treemap)
library(sunburstR)
# Load dataset from github
data <- read.table("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/11_SevCatOneNumNestedOneObsPerGroup.csv", header=T, sep=";")
data[ which(data$value==-1),"value"] <- 1
colnames(data) <- c("Continent", "Region", "Country", "Pop")
# Reformat data for the sunburstR package
data <- data %>%
filter(Continent != "") %>%
mutate(path = paste(Continent, Region, Country, sep="-")) %>%
dplyr::select(path, Pop)
# Plot
p <- sunburst(data, legend=FALSE)Note: This figure is interactive: hover a region to show the country and its architecture.
Flows
Sunburst diagrams can also be used to represent flows. In this case they are more comparable to a Sankey diagram. The following example describe the professional state evolution of a set of people:
Show codeHide code
library(TraMineR)
library(sunburstR)
library(pipeR)
# use example from TraMineR vignette
data("mvad")
mvad.alphab <- c(
"employment", "FE", "HE", "joblessness",
"school", "training"
)
mvad.seq <- seqdef(mvad, 17:86, xtstep = 6, alphabet = mvad.alphab)
# to make this work, we'll compress the sequences with seqdss
# could also aggregate with dply later
seqtab( seqdss(mvad.seq), tlim = 0, format = "SPS" ) %>>%
attr("freq") %>>%
(
data.frame(
# appending "-end" is necessary for this to work
sequence = paste0(
gsub(
x = names(.$Freq)
, pattern = "(/[0-9]*)"
, replacement = ""
, perl = T
)
,"-end"
)
,freq = as.numeric(.$Freq)
,stringsAsFactors = FALSE
)
) %>>%
sunburst ->pNote: This graphic comes from the sunburstR package documentation. Thanks to timelyportfolio for his work.
Downsides
- Labels - It is very hard to represent labels on sunburst charts. This is why using
interactivityas above is often necessary to make the chart useful. This is an important downside though: it is hard to understand the figure in a glimpse. - Angles are hard to read - sunburst suffers the same issue than pie or donut chart. The human eye is bad at reading angles. As a consequence, it is hard to deduce values behind items accurately.
- Deeper slices are exagerated - by construction, outer parts tend to get bigger than inner part for a same value. Indeed, the perimeter of the circle gets longer when you go further from the center of the circle!
Related
HeatmapRepresentation of data where the individual values contained in a matrix are represented as colors
Circular packingA circular version of a Treemap to visualize a hierarchical organization
Sunburst DiagramDisplay a hierarchy through a set of nested donut plots.
DendrogramA network structure used to show a hierarchical organization.Build your own
The R, Python, React and D3 graph galleries are 4 websites providing hundreds of chart example, always providing the reproducible code. Click the button below to see how to build the chart you need with your favorite programing language.
