How to create png file for multiple charts using X11 in R?

Asked

Viewed 241 times

1

I was able to plot and generate files (png) of the simple graphics, but in the case of several charts in the same window (as in the case of X11) I cannot 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()

You can save the chart using png(filename=nome_do_grafico.png) and dev.off()? Where is the error?

1 answer

2


x11() is a function to create a new graphical window in R. For multiple charts in the same window, you use the option mfrow = c(x, y) within the function par() (What you’re already wearing).

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

Motive: When you save a chart with png(), you are opening a new graphical window. So if you use x11() after png() you are opening a new window, disabling the function png().

  • Thank you so much! I had already tried to eliminate the X11 line and it worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.