[R] Plotting multiple xyplots in same page
Duncan Mackay
mackay at northnet.com.au
Thu Feb 14 12:06:37 CET 2013
Hi Lisa
I did something like what you want several months ago but cannot find it.
I think I used viewport in the grid package and it was a case of
using several viewports withing a tree akin to what you have been
doing with print.
Paul Murrell's book R Graphics 2nd edition may be of use
Sorry cannot give you any more help
Regards
Duncan
At 17:09 14/02/2013, you wrote:
>Dear Duncan and Pascal, Thank you for the response. Duncan: I was
>able to fix the space between title and figure. I would also like
>to have separate main titles for each row of figures in addition to
>the individual titles. xy <-xyplot(decrease ~ treatment,
>OrchardSprays, main= "Some plot", groups = rowpos, type
>= "a", page =
>function(n){ grid.text(LETTERS[j],
> y = 0.95, x =
>0.15, default.units =
>"npc", just =
>c("left"), gp = gpar(fontsize =
>12,fontface="bold") ) }, par.settings =
>c(simpleTheme(lty=1:8, col="black",lwd=2),list(layout.heights =
>list(main = 1.2, sub =
>0, axis.top =
>0.2, top.padding =
>0.1, bottom.padding = 0)) ), auto.key
>= list(x = 0.2, y = 0.9, cex = 0.75, points = FALSE, lines =
>TRUE)) j=1 print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more = TRUE)
>j=j+1 print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more = TRUE) j=j+1
>print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more = TRUE) j=j+1
>print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more = TRUE) j=j+1 print(xy,
>pos = c(0.33, 0.0, 0.66, 0.5), more = TRUE) j=j+1 print(xy, pos =
>c(0.66, 0.0, 0.99, 0.5), more = FALSE) Pascal: I would prefer not to
>use panels as this is for publication purpose. Many thanks, Lisa
>----- Original Message ----- From: Duncan Mackay
><mackay at northnet.com.au> To: Lisa Daniel <lisadaniel2013 at yahoo.com>;
>r-help-r-project.org <r-help at r-project.org> Cc: Sent: Wednesday,
>February 13, 2013 7:53 PM Subject: Re: [R] Plotting multiple xyplots
>in same page Hi Lisa have a look at par.settings in ?xyplot
>trellis.par.get() shows the settings trellis.par.get()[[27]] $left
>$left$tck [1] 1 $left$pad1 [1] 1 $left$pad2 [1] 1 $top $top$tck [1]
>1 $top$pad1 [1] 1 $top$pad2 [1] 1 $right $right$tck [1] 1
>$right$pad1 [1] 1 $right$pad2 [1] 1 $bottom $bottom$tck [1] 1
>$bottom$pad1 [1] 1 $bottom$pad2 [1] 1 as an example: par.settings =
>list( layout.heights = list(main = 0, sub =
>0, axis.top =
>0.2, top.padding =
>0, bottom.padding = 0) ) HTH Duncan Duncan
>Mackay Department of Agronomy and Soil Science University of New
>England Armidale NSW 2351 Email: home: mackay at northnet.com.au At
>09:10 14/02/2013, you wrote: >Dear Rhelp, > >I was able to plot 6
>figures in one page. I do need help in >reducing the space between
>the title and the plot and assigning >A,B,C,D,E,F to each
>figure >library(lattice) >trellis.par.set(theme = col.whitebg()) >xy
><- xyplot(decrease ~ treatment, OrchardSprays, > main="Some
>plot", > groups = rowpos, type =
>"a", > auto.key = list(x = 0.2, y =
>0.9, > cex = 0.52, points = FALSE, lines =
>TRUE)) > > >print(xy, pos = c(0.0, 0.5, 0.33, 1.0), more =
>TRUE) >print(xy, pos = c(0.33, 0.5, 0.66, 1.0), more =
>TRUE) >print(xy, pos = c(0.66, 0.5, 0.99, 1.0), more =
>TRUE) >print(xy, pos = c(0.0, 0.0, 0.33, 0.5), more =
>TRUE) >print(xy, pos = c(0.33, 0.0, 0.66, 0.5), more =
>TRUE) >print(xy, pos = c(0.66, 0.0, 0.99, 0.5), more =
>FALSE) > >Thanks in advance, >Lisa > > > >----- Original Message
>----- >From: Lisa Daniel <lisadaniel2013 at yahoo.com> >To:
>"r-help at r-project.org" <r-help at r-project.org> >Cc: >Sent: Wednesday,
>February 13, 2013 5:28 PM >Subject: Plotting multiple xyplots in
>same page > >Dear Rhelp, > >I would like to have 6 xyplots in the
>same page. Similar to >(par(mfrow=c(3,3)) >Found this example on
>the R archives. >library(lattice) >trellis.par.set(theme =
>col.whitebg()) >xy <- xyplot(decrease ~ treatment,
>OrchardSprays, > groups = rowpos, type =
>"a", > auto.key = list(x = 0.2, y =
>0.9, > cex = 0.75, points = FALSE, lines =
>TRUE)) > >print(xy, pos = c(0.0, 0.0, 0.5, 0.5), more =
>TRUE) >print(xy, pos = c(0.0, 0.5, 0.5, 1.0), more =
>TRUE) >print(xy, pos = c(0.5, 0.0, 1.0, 0.5), more =
>TRUE) >print(xy, pos = c(0.5, 0.5, 1.0, 1.0), more =
>FALSE) > > > > >When I changed the print() to: > > print(xy,
>pos=c(0.0,0.0,0.33,0.33),more = TRUE), >the figure was not looking
>good. > >Also, is it possible to assign A, B, C,D, etc for each
>figure. > > > >a<- rnorm(1000,0,1) >b<- rnorm(1000,0,2) >c<-
>rnorm(1000,0,3) >d<-
>rnorm(1000,0,4) >par(mfrow=c(2,2)) >hist(a,main="") >title(main="A",a
>dj=0) >hist(b,main="") >title(main="B",adj=0) >hist(c,main="") >title
>(main="C",adj=0) >hist(d,main="") >title(main="D",adj=0) > > >I
>tried this to xyplot, but it was not working. > >Please help
>me. > >Many thanks in
>advance, >Lisa. > > >______________________________________________ >
>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.
More information about the R-help
mailing list