[R] Multiple plots; single x(y) labels

Shi, Tao shidaxia at yahoo.com
Fri May 14 19:29:47 CEST 2010


Gurmeet,

I think Xin is more interested in the common axes, rather than just one single xlab or ylab.

Jim's solution is much more fancier than mine :-)

...Tao




----- Original Message ----
> From: Gurmeet <r.emailing.list at gmail.com>
> To: Jim Lemon <jim at bitwrit.com.au>
> Cc: r-help at r-project.org
> Sent: Fri, May 14, 2010 10:00:03 AM
> Subject: Re: [R] Multiple plots; single x(y) labels
> 
> Hi Xin,

Or, just try adding "oma" and "mtext" 
> commands:

?par
?mtext

# 
> Code
par(mfcol=c(2,2))
par(oma=c(2,2,0,0))
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="")
mtext("One x-label", side = 1, 
> outer=TRUE)
mtext("One y-label", side = 2, 
> outer=TRUE)

~Gurmeet


On Fri, May 14, 2010 at 4:14 AM, Jim 
> Lemon <
> href="mailto:jim at bitwrit.com.au">jim at bitwrit.com.au> wrote:

> 
> 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
>
>
> 
> ______________________________________________
> 
> ymailto="mailto:R-help at r-project.org" 
> href="mailto:R-help at r-project.org">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.
>

    [[alternative HTML version 
> deleted]]

______________________________________________

> ymailto="mailto:R-help at r-project.org" 
> href="mailto:R-help at r-project.org">R-help at r-project.org mailing list

> href="https://stat.ethz.ch/mailman/listinfo/r-help" target=_blank 
> >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.



More information about the R-help mailing list