Based on the answer https://stackoverflow.com/a/26748780/1172302 and the following data
"Category","Driver","Intensity","Intensity (Numeric)","Intensity (Fraction)","ymin","ymax","Color"
"Ec","Loss","High",2,0.0833333333,0,0.0833333333,"orange"
"Ec","Stress","High",2,0.0833333333,0.0833333333,0.1666666666,"orange"
"Ec","Expectations","High",2,0.0833333333,0.1666666666,0.2499999999,"orange"
"Go","Lack","Very high",3,0.125,0.2499999999,0.3749999999,"red"
"Go","Competition","Very high",3,0.125,0.3749999999,0.4999999999,"red"
"So","Disrespect","Low",1,0.0833333333,0.4999999999,0.5833333332,"yellow"
"So","Harassment","High",2,0.0833333333,0.5833333332,0.6666666665,"orange"
"So","Upheaval","Low",1,0.0833333333,0.6666666665,0.7499999998,"yellow"
"Se","Vulnerability","High",2,0.0833333333,0.7499999998,0.8333333331,"orange"
"Se","Police","Very high",3,0.0833333333,0.8333333331,0.9166666664,"red"
"Se","Presence","Low",1,0.0833333333,0.9166666664,0.9999999997,"yellow"
a pie can be derived via
# prepare data
cd <- read.csv("piedata.csv", header = TRUE, check.names = FALSE )[1:8]
cd[[2]] <- as.character(cd[[2]])
cd[[3]] <- factor(cd[[3]], levels(cd[[3]])[c(2, 1, 3)])
# load library
library(ggplot2)
# plot
ggplot(cd) +
geom_rect( aes ( fill = cd[[2]],
ymax = ymax, ymin = ymin, xmax = 4, xmin = 2)) +
geom_rect( aes ( fill = cd[[1]],
ymax = ymax, ymin = ymin, xmax = 2, xmin = 0)) +
xlim( c(0, 4)) +
theme(aspect.ratio = 1) +
coord_polar(theta="y") + theme_void()
How can I use the colors defined in cd$Color
for the segments of the outer circle, define another four custom colors for the inner circle and, finally, avoid having the categories from cd$Category
("Ec", "Go", "So" and "Se") be present in the legend alltogether?