definition - mistake - related - code


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

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

# Load dataset from github
data <- read.table("", 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:


# use example from TraMineR vignette
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") %>>%
      # appending "-end" is necessary for this to work
      sequence = paste0(
          x = names(.$Freq)
          , pattern = "(/[0-9]*)"
          , replacement = ""
          , perl = T
      ,freq = as.numeric(.$Freq)
      ,stringsAsFactors = FALSE
  ) %>>%
  sunburst ->p

Note: This graphic comes from the sunburstR package documentation. Thanks to timelyportfolio for his work.



Build your own

The R and Python graph galleries are 2 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.

R graph gallery Python gallery


Any thoughts on this? Found any mistake? Disagree? Please drop me a word on twitter or in the comment section below:


A work by Yan Holtz for