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:
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.
# 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.
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:
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 ->p
Note: This graphic comes from the sunburstR package documentation. Thanks to timelyportfolio for his work.
interactivity
as 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.Data To Viz is a comprehensive classification of chart types organized by data input format. Get a high-resolution version of our decision tree delivered to your inbox now!
A work by Yan Holtz for data-to-viz.com