Graph Help - Circular Barplot

Viewed 164

I've no idea where to even start with this. I've looked at GGPlot and plotly etc to try and find the right thing but haven't come across anything.

This is as example of my data though

Skill <- c("Tackling", "Shooting", "Technique", "Passing", "Pace", "Stamina")
Grade <- c("A", "C", "C", "B", "A", "B")
data <- data.frame(Skill, Grade)

This is the sort of graph I'd like enter image description here

I'm a football scout and it would be fantastic to be able to have a graph like that to compare the players we have to the player I'm scouting.

so if the grade is D, it would just show red, if the grade was C it would show red and orange. Etc.

3 Answers

This is quite close to what you want:

Skill <- c("Tackling", "Shooting", "Technique", "Passing", "Pace", "Stamina")
Grade <- c("A", "C", "C", "B", "A", "B")
data <- data.frame(Skill, Grade)

library(ggplot2)
library(dplyr)

data$grade <- factor(data$Grade, levels=c("D","C","B","A"))
data$grade2 <- recode(data$grade, A="B")
data$grade3 <- recode(data$grade2, B="C")
data$grade4 <- recode(data$grade3, C="D")

ggplot(data, aes(x=Skill, y=grade)) + 
  geom_bar(stat="identity", fill="green",col="black",width=1)  + 
  geom_bar(aes(y=grade2),stat="identity", fill="yellow",col="black",width=1)  + 
  geom_bar(aes(y=grade3),stat="identity", fill="orange",col="black",width=1)  + 
  geom_bar(aes(y=grade4),stat="identity", fill="red",col="black",width=1)  + 
  scale_y_discrete(limits = c("D","C","B","A")) + 
  coord_polar(start = pi/6) + theme_bw() + theme(axis.text.y = element_blank()) + 
  theme(axis.ticks = element_blank(), axis.title = element_blank()) 


enter image description here

How about this

library(ggplot2)

ggplot(data = data, aes(Skill, Grade, fill = Grade)) + 
      geom_tile() +
      coord_polar() +
      theme_bw()

To have all levels below the grade coded, you'll need to have all those lower levels within the dataframe, which is in a way redundant. Wouldn't it be?

d = transform(data, gr = as.numeric(factor(data$Grade, c("D", "C", "B", "A"))))
d = do.call(rbind, lapply(split(d, d$Skill), function(x){
    foo = with(x, setNames(data.frame(Skill[1], Grade[1], seq(gr)), names(x)))
}))

library(ggplot2)
ggplot(d, aes(Skill, gr, fill = factor(gr, 4:1))) +
    geom_col() +
    coord_polar()
Related