ggplot正在导出空图像

时间:2014-12-05 09:44:17

标签: r image ggplot2

我将图表导出为png个文件。我正在单独导出绘图,然后使用grid.arrange将绘图导出到一起。 grid.arrange导出png文件就好了,但是单独保存的图表会返回并在同一文件夹中清空图像。图像实际上是绘图大小,但图形/标题是明显的。下面的代码显示了我的绘图方式。

########## Cy5 individual plots############

png(file='10pMcomp_plots/DNA01_Cy5_10pM.png',width=600,height=600,res=100)
AllCy5MeansDNA1bind10pMwithoutcontrols<-melt(AllCy5MeansDNA1bind10pMwithoutcontrols, id=c("Spot_Size","Molarity","Mean Fluorescence"))
DNA1Cy5_10pm<-ggplot(AllCy5MeansDNA1bind10pMwithoutcontrols, aes(x=as.factor(Molarity), y=AllCy5MeansDNA1bind10pMwithoutcontrols$Mean, fill=Spot_Size)) +  geom_bar(stat = "identity", position = "dodge") + ylab("Mean Fluorescence") + ylim(0,650)  +xlab("Molarity (uM)") + ggtitle("Trimmed Mean of Cy5 Fluorescence \n with DNA 01 probe.")+ theme(plot.title = element_text(size = 15))
dev.off()

png(file='10pMcomp_plots/DNA02_Cy5_10pM.png',width=600,height=600,res=100)
AllCy5MeansDNA2bind10pMwithoutcontrols<-melt(AllCy5MeansDNA2bind10pMwithoutcontrols, id=c("Spot_Size","Molarity","Mean Fluorescence"))
DNA2Cy5_10pm<-ggplot(AllCy5MeansDNA2bind10pMwithoutcontrols, aes(x=as.factor(Molarity), y=AllCy5MeansDNA2bind10pMwithoutcontrols$Mean, fill=Spot_Size)) +  geom_bar(stat = "identity", position = "dodge") + ylab("Mean Fluorescence") + ylim(0,650)  + xlab("Molarity (uM)") + ggtitle("Trimmed Mean of Cy5 Fluorescence \n with DNA 02 probe. ")+ theme(plot.title = element_text(size = 15))
dev.off()

png(file='10pMcomp_plots/DNA01_Cy5_10pM.png',width=600,height=600,res=100)
AllCy5MeansDNA19bind10pMwithoutcontrols<-melt(AllCy5MeansDNA19bind10pMwithoutcontrols, id=c("Spot_Size","Molarity","Mean Fluorescence"))
DNA19Cy5_10pm<-ggplot(AllCy5MeansDNA19bind10pMwithoutcontrols, aes(x=as.factor(Molarity), y=AllCy5MeansDNA19bind10pMwithoutcontrols$Mean, fill=Spot_Size)) +  geom_bar(stat = "identity", position = "dodge") + ylab("Mean Fluorescence") + ylim(0,650)  +xlab("Molarity (uM)") + ggtitle("Trimmed Mean of Cy5 Fluorescence \n with DNA 19 probe.")+ theme(plot.title = element_text(size = 15))
dev.off()

png(file='10pMcomp_plots/DNA02_Cy5_10pM.png',width=600,height=600,res=100)
AllCy5MeansDNA20bind10pMwithoutcontrols<-melt(AllCy5MeansDNA20bind10pMwithoutcontrols, id=c("Spot_Size","Molarity","Mean Fluorescence"))
DNA20Cy5_10pm<-ggplot(AllCy5MeansDNA20bind10pMwithoutcontrols, aes(x=as.factor(Molarity), y=AllCy5MeansDNA20bind10pMwithoutcontrols$Mean, fill=Spot_Size)) +  geom_bar(stat = "identity", position = "dodge") + ylab("Mean Fluorescence") + ylim(0,650)  + xlab("Molarity (uM)") + ggtitle("Trimmed Mean of Cy5 Fluorescence \n with DNA 20 probe.")+ theme(plot.title = element_text(size = 15))
dev.off()

#########ARRAY OF PLOTS#############
png(file='10pMcomp_plots/Cy5_10pM.png',width=800,height=800,res=100)

grid.arrange(DNA1Cy5_10pm, DNA2Cy5_10pm, DNA19Cy5_10pm, DNA20Cy5_10pm, ncol=2, main =  "Cy5 Fluorescence with 10pM complement" )
dev.off()

任何帮助都将不胜感激。

0 个答案:

没有答案