I am trying to use the jpeg function in R to save graphics automatically. The function works perfectly if I just use the default graphics device and do not try to alter it. But when I try and alter the device by the 'X11' function it does not work (I think it is recording the null device and not the X11 device).Below is some code you can run your self. Any help would be greatly appreciated!
x<-rnorm(10, 3, 4)
y<-rnorm(10, 68, 2)
jpeg(file="YOUR FILE PATH", quality=100)
X11(width=20, height=15)
par(mfrow=c(2,2))
plot(x,y, main="1")
plot(x,y,main="2")
plot(x,y, main="3")
plot(x,y,main="4")
dev.off()
jpeg and X11 are in some sense competing devices. You can only output to one thing at a time. So when you call X11 after jpeg, you are telling R to send all output to the X11 device. Take out X11 and pass your height and width arguments directly to jpeg.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With