I would like to make a graph with ggplot as shown below. The idea is to plot \"percentage matches\" between two categorical variables. It is easy to come close by altering the s
First, modify your original data frame to have first 6 rows containing original score and last 6 rows contains 1 minus original score. Then added column group containing levels for those two groups.
temp <- data.frame(Exercise=c(1, 1, 1, 2, 2, 2),
Name=c(1, 2, 3, 1, 2, 3), Score=c(0.2, 0.5, 0.3, 0.9, 1.0, 0.6))
temp<-rbind(temp,temp)
temp$Score[7:12]<-1-temp$Score[1:6]
temp$group<-rep(c("poz","neg"),each=6)
coord_polar() is used to make piecharts from barplot and then facet_grid() to make six small plots. theme() is used to remove axis, facet labels, gridlines.
ggplot(temp,aes(x = factor(1),y=Score,fill=group)) +
geom_bar(width = 1, stat = "identity") + facet_grid(Exercise~Name)+
coord_polar(theta = "y") +
scale_fill_manual(values = c("black", "grey")) +
theme_bw() + scale_x_discrete("",breaks=NULL) + scale_y_continuous("",breaks=NULL)+
theme(panel.border=element_blank(),
strip.text=element_blank(),
strip.background=element_blank(),
legend.position="none",
panel.grid=element_blank())
