Hi All, Can anyone please help me with getting a single x and y-axis label while plotting muliple plots. Here is the code: par(mfcol=c(2,2)) plot(x <- sort(rnorm(7)), type = "s", main = "", ylab="", xlab="") plot(x <- sort(rnorm(27)), type = "s", main = "", ylab="", xlab="") plot(x <- sort(rnorm(47)), type = "s", main = "", ylab="", xlab="") plot(x <- sort(rnorm(67)), type = "s", main = "", ylab="", xlab="") also, how can remove x-tick lables using plot()? Thanks, Xin [[alternative HTML version deleted]]
?plot # ylim and you need to have the data in a form (before plotting) where you can determine the shared max and min for the y limits On May 13, 2010, at 12:04 PM, Xin Ge wrote:> Hi All, > > Can anyone please help me with getting a single x and y-axis label > while > plotting muliple plots. Here is the code: > > par(mfcol=c(2,2)) > plot(x <- sort(rnorm(7)), type = "s", main = "", ylab="", xlab="") > plot(x <- sort(rnorm(27)), type = "s", main = "", ylab="", xlab="") > plot(x <- sort(rnorm(47)), type = "s", main = "", ylab="", xlab="") > plot(x <- sort(rnorm(67)), type = "s", main = "", ylab="", xlab="")opar <- par(mfcol=c(2,2)) randlist <- list(); randlist[[1]] <- sort(rnorm(7)) randlist[[2]] <- sort(rnorm(27)) randlist[[3]] <- sort(rnorm(47)) randlist[[4]] <- sort(rnorm(67)) lapply(randlist, plot, ylim=c(min(rapply(randlist, min)), max(rapply(randlist,max))), type = "s", xaxt="n", main = "", ylab="", xlab=""); par(opar)> > also, how can remove x-tick lables using plot()??par # xaxt="n"> > Thanks, > Xin > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT
Try this: x1 <- rnorm(7) x2 <- rnorm(27) x3 <- rnorm(47) x4 <- rnorm(67) xyplot(value ~ i | id, do.call(rbind, lapply(ls(patt = "x"), function(x)data.frame(id = x, value = get(x), i = seq_along(get(x))))), type='l') On Thu, May 13, 2010 at 1:04 PM, Xin Ge <xingemaillist@gmail.com> wrote:> Hi All, > > Can anyone please help me with getting a single x and y-axis label while > plotting muliple plots. Here is the code: > > par(mfcol=c(2,2)) > plot(x <- sort(rnorm(7)), type = "s", main = "", ylab="", xlab="") > plot(x <- sort(rnorm(27)), type = "s", main = "", ylab="", xlab="") > plot(x <- sort(rnorm(47)), type = "s", main = "", ylab="", xlab="") > plot(x <- sort(rnorm(67)), type = "s", main = "", ylab="", xlab="") > > also, how can remove x-tick lables using plot()? > > Thanks, > Xin > > [[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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
On 05/14/2010 02:04 AM, Xin Ge wrote:> Hi All, > > Can anyone please help me with getting a single x and y-axis label while > plotting muliple plots. Here is the code: > > par(mfcol=c(2,2)) > plot(x<- sort(rnorm(7)), type = "s", main = "", ylab="", xlab="") > plot(x<- sort(rnorm(27)), type = "s", main = "", ylab="", xlab="") > plot(x<- sort(rnorm(47)), type = "s", main = "", ylab="", xlab="") > plot(x<- sort(rnorm(67)), type = "s", main = "", ylab="", xlab="") > > also, how can remove x-tick lables using plot()? >Hi Xin, Fortunately, this wheel is pretty easy to reinvent: require(plotrix) x1<-rnorm(7) x2<-rnorm(27) x3<-rnorm(47) x4<-rnorm(67) allxlim<-c(1,67) allylim<-range(c(x1,x2,x3,x4)) panes(matrix(1:4,nrow=2,byrow=TRUE),widths=c(1.1,1), heights=c(1,1.1)) par(mar=c(0,4,2,0)) plot(sort(x1),xlim=allxlim,ylim=allylim,type="s", main="",ylab="",xlab="",xaxt="n") tab.title("Plot of x1",tab.col="orange") par(mar=c(0,0,2,1)) plot(sort(x2),xlim=allxlim,ylim=allylim,type="s", main="",ylab="",xlab="",xaxt="n",yaxt="n") tab.title("Plot of x2",tab.col="orange") par(mar=c(4,4,2,0)) plot(sort(x3),xlim=allxlim,ylim=allylim,type="s", main="",ylab="",xlab="") tab.title("Plot of x3",tab.col="orange") par(mar=c(4,0,2,1)) plot(sort(x4),xlim=allxlim,ylim=allylim,type="s", main="",ylab="",xlab="",yaxt="n") tab.title("Plot of x4",tab.col="orange") Jim