Skip to content

Instantly share code, notes, and snippets.

@kkruups
Created December 19, 2018 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkruups/4cfc669ddd3052a219d622663762605b to your computer and use it in GitHub Desktop.
Save kkruups/4cfc669ddd3052a219d622663762605b to your computer and use it in GitHub Desktop.
R; R Radar Gist
# Create data: note in High school for Jonathan:
set.seed(1)
data <-as.data.frame(matrix( sample( 2:20 , 60 , replace=T) , ncol=10, byrow=TRUE))
colnames(data) <- c("math" , "english" , "biology" , "music" , "R-coding", "data-viz" , "french" , "physic", "statistic", "sport" )
# To use the fmsb package, I have to add 2 lines to the dataframe: the max and min of each topic to show on the plot!
data <-rbind(rep(20,10) , rep(0,10) , data)
# Prepare color
colors_border=colormap(colormap=colormaps$viridis, nshades=6, alpha=1)
colors_in=colormap(colormap=colormaps$viridis, nshades=6, alpha=0.3)
# Prepare title
mytitle <- c("Max", "George", "Xue", "Tom", "Alice", "bob")
# Split the screen in 6 parts
par(mar=rep(0.8,4))
par(mfrow=c(2,3))
# Loop for each plot
for(i in 1:6){
# Custom the radarChart !
radarchart( data[c(1,2,i+2),], axistype=1,
#custom polygon
pcol=colors_border[i] , pfcol=colors_in[i] , plwd=4, plty=1 ,
#custom the grid
cglcol="grey", cglty=1, axislabcol="grey", caxislabels=seq(0,20,5), cglwd=0.8,
#custom labels
vlcex=0.8,
#title
title=mytitle[i]
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment