您可以使用 ggsunburst 包非常接近
# using your data
df <- structure(list(Animal = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L), .Label = c("Buffalo",
"Goat", "Sheep"), class = "factor"), Texture = structure(c(4L,
4L, 4L, 4L, 4L, 3L, 3L, 3L, 2L, 1L, 1L, 4L, 3L, 4L, 2L, 2L, 2L,
2L, 1L, 1L, 1L, 1L), .Label = c("Hard", "Semi-Hard", "Semi-Soft",
"Soft"), class = "factor"), Name = structure(c(16L, 9L, 3L, 21L,
5L, 4L, 10L, 2L, 12L, 11L, 8L, 14L, 1L, 7L, 22L, 15L, 6L, 20L,
18L, 17L, 19L, 13L), .Label = c("Buffalo Blue", "Charolais",
"Chevre Bucheron", "Clochette", "Crottin de Chavignol", "Feta",
"Fleur du Maquis", "Garrotxa", "Golden Cross", "Humboldt Fog",
"Idaho Goatster", "Majorero", "Manchego", "Mozzarella di Bufala Campana",
"Ossau-Iraty", "Pantysgawn", "Pecorino Romano", "Pecorino Sardo",
"Roncal", "Roquefort", "Sainte-Maure de Touraine", "Yorkshire Blue"
), class = "factor")), .Names = c("Animal", "Texture", "Name"
), class = "data.frame", row.names = c(NA, -22L))
# add special attribute "dist" using "->" as sep, this will increase the size of the terminal nodes to make space for the cheese names
df$Name <- paste(df$Name, "dist:3", sep="->")
# save data.frame into csv without row and col names
write.table(df, file = 'df.csv', sep = ",", col.names = F, row.names = F)
# install ggsunburst package
if (!require("ggplot2")) install.packages("ggplot2")
if (!require("rPython")) install.packages("rPython")
install.packages("http://genome.crg.es/~didac/ggsunburst/ggsunburst_0.0.9.tar.gz", repos=NULL, type="source")
library(ggsunburst)
# generate data structure from csv and plot
sb <- sunburst_data('df.csv', type = "lineage", sep=",")
sunburst(sb, node_labels = T, node_labels.min = 15, rects.fill.aes = "name") +
scale_fill_manual(values = c("#EEC900", "#FFD700", "#CD9B1D",
"#FFD700", "#DAA520", "#EEB422", "#FFC125", "#8B6914", "#EEC591",
"#FFF8DC", "#EEDFCC", "#FFFAF0", "#EEC900", "#FFD700", "#CDAD00",
"#FFF68F", "#FFEC8B", "#FAFAD2", "#FFFFE0", "#CD853F", "#EED8AE",
"#F5DEB3", "#FFFFFF", "#FFFACD", "#D9D9D9", "#EE7600", "#FF7F00",
"#FFB90F", "#FFFFFF"), guide = F) +
theme(panel.background = element_rect(fill = "black"))