[R] Concatenate xyplots

Deepayan Sarkar deepayan.sarkar at gmail.com
Wed Jan 30 17:46:50 CET 2008


On 1/30/08, eite2335 <jeitel at vandals.uidaho.edu> wrote:
>
> OK - here is an example:
>
> ## Create example data
>
> data = matrix(1:8, nrow=4, ncol=2)
>
> ## Name columns "x" and "y"
>
> colnames(data) = c("x", "y")
>
> data = data.frame(data)
>
> ## Create 5 graphs with the xyplot command
>
> graph1=  xyplot(y~x, data = data)
> graph2 = xyplot(y~x, data = data)
> graph3 = xyplot(y~x, data = data)
> graph4 = xyplot(y~x, data = data)
> graph5 = xyplot(y~x, data = data)
>
> ## Print all five graphs on the same page
>
> print(graph1, split = c(1,1,1,5), more = T)
> print(graph2, split = c(1,2,1,5), more = T)
> print(graph3, split = c(1,3,1,5), more = T)
> print(graph4, split = c(1,4,1,5), more = T)
> print(graph5, split = c(1,5,1,5), more = F)
>
>
> ## Note that there is a lot of white space between each graph in the y
> direction.
> ## Since the plots share the same x axis I was wondering if there is a way
> to
> ## concatenate the plots to eliminate the "wasted" white space in the y
> direction
> ## and make the graphs themselves larger?

This should work:

graph1[c(1, 1, 1, 1, 1)]

Of course, a silly example will only get you a silly solution.

-Deepayan



More information about the R-help mailing list