# [R] Concatenate xyplots

eite2335 jeitel at vandals.uidaho.edu
Wed Jan 30 17:17:14 CET 2008

```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?

Deepayan Sarkar wrote:
>
> On 1/29/08, jeitel at vandals.uidaho.edu <jeitel at vandals.uidaho.edu> wrote:
>> Dear R-community,
>>
>> I created 5 different xyplots and graphed all of them with the print
>> command on one page (e.g.
>>
>>  print(graph1, split=c(1,1,1,5), more = T)
>>
>> ... print(graph5, split=c(1,5,1,5), more =T)
>>
>> Using the above commands separates each graph by a white space. However,
>> since
>> the graphs do share the same x-axis, I was wondering if there is a way to
>> concatenate
>> graph1 through 5 so that the white space disappears?
>
> It is very likely that there is, but we can't really say without
> knowing all the little details that you know and we don't. So if you
> want any real help, please give us a minimal reproducible example as
> the footer of every r-help message asks:
>
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> -Deepayan
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help