How to create png file for multiple graphics using x11 in R?

1

I was able to plot and generate files (png) of the simple graphics, but in case of several graphics in the same window (as in the case of x11) I can not save the file in the directory.

png(filename="box_sv_sst_mean.png",width=2034,height=2034,units="px",pointsize=12,bg="white",res=300)
x11(width = 14, height = 7)
par(mfrow = c(1,2),mar=c(5,4,2,2),oma=c(0,0,2,0))
boxplot(SSTmean~year,ylab="temperatura °C",xlab="ano")
boxplot(SSTmean~month,ylab="temperatura °C",xlab="mês")
title("SST Média",outer=TRUE,cex.main=2)
dev.off()

Is it possible to save the chart using png(filename=nome_do_grafico.png) and dev.off() ? Where is the error?

    
asked by anonymous 25.10.2017 / 13:17

1 answer

2

x11() is a function to create a new graphical window in R. For several graphs in the same window, you use the mfrow = c(x, y) option within the par() (What you are already using) function.

Solution : Your problem will probably be resolved by removing the x11(width = 14, height = 7) line.

Reason : When you save a chart with png() , you are opening a new graph window. So if you use x11() after png() you are opening a new window by turning off the png() function.

    
25.10.2017 / 16:15