The par
function should be called after you open the graphics device, which in this case is done with png
. So you simply need to move that line.
Unable to generate six plots in one layout
Question
I would like to generate 6 plots in one layout, but my code generates only the last plot. This is my code:
i<-c(500,1500,2500)
for(n in i)
{
par(mfrow = c( 6, 1 ))
window<-333
Filename2<-paste("/home/blabla/Bilder/6Fenster",n,".png",sep="")
png(filename=Filename2,width = 800,height = 600)
plot(datalist[n:(n+window-1),1],type="l",col="blue",xlab=n+window,ylab="values")
x.specR<-spectrum(datalist[n:(n+window-1),1],plot=FALSE)
plot((1:180),x.specR$spec,type="l",xlab="Frequenz",ylab="Frequenz")
hfft<-hanning.window(333)*datalist[n:(n+window-1)]
x.specHF<-spectrum(hfft,plot=FALSE)
plot((1:180),x.specHF$spec,type="l",xlab="Frequenz",ylab="Frequenz")
m<-acf(datalist[n:(n+window-1),1],lag.max=333,plot=FALSE)$acf[-1]
plot(m,type="l",ylim=c(-1,1),axes=FALSE, frame.plot=TRUE)
axis(1,at=333/(1:333),labels=rev(333/(1:333)),axTicks(4))
axis(2, at=c(-1,1))
x.specA<-spectrum(m,plot=FALSE)
plot((1:180),x.specA$spec,type="l",xlab="Frequenz",ylab="Frequenz")
ha<-hanning.window(333)*m
x.specHA<-spectrum(ha,plot=FALSE)
plot((1:180),x.specHA$spec,type="l",xlab="Frequenz",ylab="Frequenz")
dev.off()
}
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow