0

I tried the using the code from https://stackoverflow.com/a/71729729/19041072, but I would like to separate the "Activation", "Swap" and "Unissued" in the sunburst plot like the following.

I was wondering if there is way to do this.

df <- data.frame(Allocation = c(rep("Activation", 8), "Swap", "Unissued"),
                 Block = c(rep("Developer", 5), rep("Grant", 3), NA, NA),
                 Work = c("Company A / Company B", "Pre-company Work",
                          "Advisory", "Protocol Contributors",
                          "Developers / incentives", "General Support",
                          "Projects", "Market makers and advisory", NA, NA),
                 Percent = c(15.8, 0.9, 0.3, 0.7, 0.3, 2.4, 2.4, 7.2, 10, 60))

df
library(tidyverse)
library(geomtextpath)

df %>%
  group_by(Allocation) %>%
  summarise(Percent = sum(Percent)) %>%
  ggplot(aes(x = 1, y = Percent, fill = Allocation)) +
  geom_col(color = "white") +
  geom_textpath(aes(label = Allocation), colour = "white", spacing = 100,
                angle = 90, size = 5, fontface = 2,
                position = position_stack(vjust = 0.5)) +
  coord_polar(theta = "y", direction = -1) +
  scale_x_continuous(limits = c(-0.5, 2)) +
  scale_fill_manual(values = c("#4285f4", "#ea4335", "#fbbc04")) +
  theme_void() +
  theme(legend.position = "none")

enter image description here

M--
  • 25,431
  • 8
  • 61
  • 93
Bertram
  • 45
  • 6

0 Answers0