[R] How to make label in multi plot
Muhammad Subianto
subianto at gmail.com
Mon May 16 12:47:50 CEST 2005
Dear Dr. Paul Murrel,
Yes, this is exactly what I need.
Thank's you very much.
Best wishes,
Muhammad Subianto
On this day 5/16/2005 5:36 AM, Paul Murrell wrote:
> Hi
>
> (cc'ed to Pierre Lapointe because this should answer the question
> about "[R] Centered overall title with layout()" as well)
>
>
> Muhammad Subianto wrote:
>
>> Dear R-Help,
>> As a reference about multi plot,
>> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48725.html
>>
>> I want to know how can I make a label for each row.
>> I mean like,
>>
>> ------------ ------------- --------------
>> | | | | | |
>> Group A | plot1 | | plot 2 | | plot 3 |
>> | | | | | |
>> ------------- ------------- --------------
>>
>> -------------
>> | |
>> Group B | plot 4 |
>> | |
>> -------------
>>
>
>
> Two ways (at least):
>
> (i) use an outer margin ...
>
> ooma <- par(oma=c(0, 5, 0, 0))
> layout(rbind(c(1, 2, 3),
> c(0, 4, 0)))
> plot(1:10, main="Plot 1")
> olas <- par(las=2)
> mtext("Group A", side=2, adj=1, outer=TRUE,
> at=0.75)
> par(olas)
> plot(1:20, main="Plot 2")
> plot(1:30, main="Plot 3")
> plot(1:40, main="Plot 4")
> olas <- par(las=2)
> mtext("Group B", side=2, adj=1, outer=TRUE,
> at=0.25)
> par(olas)
> # new page!
> plot(1:40, main="Plot 5")
> par(ooma)
>
> (ii) create an extra row/coloumn in the layout for the labels:
>
> layout(rbind(c(1, 2, 3, 4),
> c(5, 0, 6, 0)),
> widths=c(2, 5, 5, 5))
> # "plot 1" is label for row 1
> omar <- par(mar=rep(0, 4))
> plot.new()
> text(0.5, 0.5, "Group A", cex=2)
> par(omar)
> plot(1:10, main="Plot 1")
> plot(1:20, main="Plot 2")
> plot(1:30, main="Plot 3")
> # "plot 5" is label for row 2
> omar <- par(mar=rep(0, 4))
> plot.new()
> text(0.5, 0.5, "Group B", cex=2)
> par(omar)
> plot(1:40, main="Plot 4")
> # new page!
> plot(1:40, main="Plot 5")
>
>
> Paul
More information about the R-help
mailing list