内置在我的应用程序中,我能够更改调色板,包括色觉缺陷。然而,我的一张图表在 R4 上工作得很好,但在 Okabe-Ito 调色板下全是灰色的,并在图例中列出了颜色的名称。我究竟做错了什么?
data<-as.data.frame(rbind(15.29,84.71))
data<-cbind(x=c("Total Measurement Variance","Total Measurement Variance"),y=data,Group=c("Repeatability","Reproducibility"))
colnames(data)<-c("x","y","Source")
color=palette.colors(n = 8,palette = "R4")
p<-ggplot(data=data,aes(x=x,y=y,fill=Source,label=y))+
geom_bar(stat="identity")+
geom_label(aes(group=Source),fill="white",label=paste0(data$y,"%"),position=position_stack(vjust=.5))+
scale_y_continuous(labels=function (x) paste0(x,"%"))+
scale_fill_manual(values=color[-1])+
labs(title="Components of Variation",x="",y="% of Measurement Error Variance")
p
color=palette.colors(n = 8,palette = "Okabe-Ito")
p<-ggplot(data=data,aes(x=x,y=y,fill=Source,label=y))+
geom_bar(stat="identity")+
geom_label(aes(group=Source),fill="white",label=paste0(data$y,"%"),position=position_stack(vjust=.5))+
scale_y_continuous(labels=function (x) paste0(x,"%"))+
scale_fill_manual(values=color[-1])+
labs(title="Components of Variation",x="",y="% of Measurement Error Variance")
p
Run Code Online (Sandbox Code Playgroud)