0

I want to build a subplot wherein overlaying several hystograms and without normalize each hystogram. So, I thought to use the function subplot() of the library "TeachingDemos", writing the function of the first hystogram and to add the looping for the drawing of the others hystograms:

filelog<- (Sys.glob("*.log"))
y<- read.table(file="data.log",skip=2,head=T)  
ffl<- filelog[!Sys.glob("*.log") %in% "data.log"]  
subplot(hist(y,breaks=(seq(0,10,by=1),main="",xlab="",xlim=c(0,10), ylab=""
        for i in 1:length(ffl)){
        x<-read.table(file=ffl[i],skip=2,head=T)
        hist(x[,"trees"],breaks=(seq(0,10,by=1)),main="",xlab="",xlim=c(0,10),        ylab="",axes=FALSE),
grconvertX(c(.7, .9), "user"), grconvertY(c(.1, .4), "user"))}
}
dev.off()

It doesn't work. Do you know why? I was thinking that maybe I have missed the way to do a function within another function.

CafféSospeso
  • 1,101
  • 3
  • 11
  • 28
  • You need par(new=TRUE) – Petr Matousu Mar 08 '15 at 13:44
  • Please provide e [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). The code your provided will not work at all. The example data is missing, there are syntax errors etc. – lukeA Mar 08 '15 at 13:45
  • I have edited the questions, in order to be more correct. And where I should put the par(new=TRUE)? – CafféSospeso Mar 08 '15 at 13:55
  • @user29859 , if you want to plot several plots, one way is to use par(new=TRUE) , for example you can do plot(x,y) then par(new=TRUE) , then plot your second data etc (look at this post http://stackoverflow.com/questions/2564258/plot-2-graphs-in-same-plot-in-r ) –  Mar 08 '15 at 14:18
  • Yes, thank you. And overlaying these subplots, they will use the same x-y scale or they will be normalized each one for each own scale? – CafféSospeso Mar 08 '15 at 15:06
  • @user29859 you can use xlim , ylim to set it up, in general try it out and if you face any problem, ask a new question with the exact problem –  Mar 08 '15 at 15:19

0 Answers0