ggplot2只能对数据框进行操作
a<-read.table("BRCA.temp.txt",head=T,sep="\t")##读入数据框
require(reshape2);
require(ggplot2);

b<-melt(a)#用reshape2的melt一下,转换为标准的数据框


#我们想要画的图是横坐标为Normal、S1、S2、S3、S4、Early、Advance,纵坐标为其共表达系数,填色根据时期区分
p<-ggplot(b,aes(x=variable,y=value))+geom_boxplot(aes(fill=variable))##横坐标、纵坐标、填色

p <- p + xlab("Stage") + ylab("R2") + ggtitle("BRCA") +guides(fill=guide_legend(title="Legend_Title"))

网友评论