Hmm.. this how my code looks like inside my function plot(density(100*datalist[[1]]$dataset$Utilization), xlab="Overall utilization [ % ]", main="", ...) colorList=colors()[seq(10,100,10)] colorList[1]="black" if (length(datalist) > 1) { for (i in 2:length(datalist)) { lines(density(100*datalist[[i]]$dataset$Utilization), lty=i, col= colorList[i]) } }
given on input a datalist the code above just by reading element by element of the list adds the corresponding line(..) I fail to see how I can calculate the min and max and then call the first plot with the right lim. Could you please help me? Regards Alex ________________________________ From: Jim Lemon <j...@bitwrit.com.au> Cc: R help <R-help@r-project.org> Sent: Thursday, March 22, 2012 8:13 AM Subject: Re: [R] Automaticall adjust axis scales On 03/22/2012 05:42 AM, Alaios wrote: > Would it be possible to change the axis at the end? > My data sets seem to be quite large so I was thinking for the plot and > the consequent lines to keep always > the current minimum and maximum like > plot(x) > minimum=min(x) > lines(x1) > minimum=c(minimum,x1) > lines(x2) > minimum=c(minimum,x2) > then if there is a good way for altering axis lines I could put the > limits I want to. Hi Alex, One way or another you are going to have to set the limits in your first call to "plot". You could do the plot first and collect the limits along the way, then do it again, but I can't see that this has any advantage over calculating the limits for the entire set of data that is to be plotted at the beginning and then doing the plots. If you want to get the limits for each data set separately, maybe: range1<-range(x1) range2<-range(x2) range3<-range(x3) ylim<-range(c(range1,range2,range3)) However, I suspect that this is of more use in helping you understand what is happening than actually getting it done. Jim [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.