简体   繁体   中英

R ggplot2 scale_fill_manual not working but scale_colour_manual works

I have no idea why scale_fill_manual isn't working here, while scale_shape_manual and scale_colour_manual does.I've searched but none solved the problem. R code:

    ggplot(Alltable,aes(x=Alltable$feature,
       y=Alltable$data.Nonsynonymous.tumor.mutation.burden,
       fill=Alltable$feature,
       shape=Alltable$feature,colour=Alltable$feature))+
       labs(x='',y='Tumor mutation burden')+
       theme_classic()+
       geom_boxplot(fill="white",color="black",lwd=1)+
       geom_quasirandom(size=1.5,width=0.3,varwidth=T)+
       scale_colour_manual(values=c("CR/PR"<-"blue","SD/PD"<-"red","DCB"<-"green3","NDB"<-"purple"))+
       scale_shape_manual(values=c("CR/PR"=1,"SD/PD"=0,"DCB"=6,"NDB"=5))+
       scale_fill_manual(values=c("CR/PR"<-"blue","SD/PD"<-"red","DCB"<-"green3","NDB"<-"purple"))+
       theme(legend.position="none")

I figured out! In scale_shape_manual(values=c("CR/PR"=1,"SD/PD"=0,"DCB"=6,"NDB"=5)) ,the shapes are hollow. Changing to scale_shape_manual(values=c("CR/PR"=21,"SD/PD"=22,"DCB"=25,"NDB"=23)) will do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM