我有一个六人表现的数据集。我想显示“最低”和“目标”性能——在这个例子中,分别是 100 和 140。
require("ggplot2")
stones<-c("Mick","Keith","Brian","Bill","Charlie","Ronnie")
rMat<-data.frame(c(rep(100,6),rep(40,6),20,21,27,46,138,168),
c(rep(1:6,3)),c(rep(stones,3)))
colnames(rMat)<-c("X1","X2","X3")
colors <- c("white","#F2F2F2","#E5E5FF", "white","#F2F2F2","#CCCCFF", "white","#F2F2F2","#B2B2FF","white","#F2F2F2", "#9999FF", "white","#F2F2F2","#7F7FFF","white","#F2F2F2","#6666FF")
gp<-ggplot(NULL,aes(X2,X1),label=rROC[,1])+theme_bw()
gp<-gp+geom_bar(data=rMat,stat="identity",fill=colors,colour="gray")
gp<-gp+coord_flip()
gp<-gp+ylab("Performance")+xlab("")
gp<-gp+scale_x_discrete(labels=rMat[,3])
gp
我已将数据分成每人三行(从 0 到最小值,从最小值到目标,然后是其余的。
y 轴刻度标签超过六个,因此名称不匹配(例如,Ronnie 的性能最高,而不是 Mick)。
我以前每人有一排(带有工作标签),如下所示:
perf<-c(160,161,167,186,278,308)
stones<-c("Mick","Keith","Brian","Bill","Charlie","Ronnie")
rMat<-data.frame(perf,c(1:6),stones)
但是,我无法像上面的示例那样拆分条形图。请任何人建议如何让标签和拆分条工作?
谢谢