Create radar chart with upper and lower quantiles using fmsb package in R

40 views Asked by At

I try to create a radar chart with bands representing the 5% and 95% quantiles for misters. There are three bands for mister a to c. How to add the upper boundary of the band matches the values of each metric at the 95% values in the distribution (quantile(data, 0.95)) , and the bottom band is the 5% (quantile(data, 0.05))? What I expected is something similar to shaded error band.

library(fmsb)
data <- as.data.frame(matrix( sample( 0:20 , 15 , replace=F) , ncol=5))
colnames(data) <- c("apple" , "banana" , "bear" , "orange" , "melon" )
rownames(data) <- paste("mister" , letters[1:3] , sep="-")

data <- rbind(rep(20,5) , rep(0,5) , data)

colors_border=c( rgb(0.2,0.5,0.5,0.9), rgb(0.8,0.2,0.5,0.9) , rgb(0.7,0.5,0.1,0.9) ) 
colors_in=c( rgb(0.2,0.5,0.5,0.4), rgb(0.8,0.2,0.5,0.4) , rgb(0.7,0.5,0.1,0.4) ) 

p <- radarchart(data  , axistype=4 ,  
                 pcol=colors_border , pfcol=colors_in , plwd=4 , plty=1,
                 cglcol="grey", cglty=1, axislabcol="grey", caxislabels=seq(0,20,5), cglwd=0.8,
                 vlcex=0.8 
)

legend(x=0.7, y=1, legend = rownames(data[-c(1,2),]), bty = "n", pch=20 , col=colors_in , text.col = "grey", cex=1.2, pt.cex=3)

Something like this: enter image description here

Source: http://www.systat.de/SigmaPlot_Graph-Beispiele.html Accessed 10 January 2024.

0

There are 0 answers