# Retaining X axis labels when combining lattice graphs

#### Bevan

##### New Member
I am attempting to create a plot that includes boxplots demonstrating the response of a variable (a0) to changes in two factors (Habitat Aamount, and Number of Patches) as two vertical panels (data set pasted at end and included as attachment). I am able to combine the two plots using the c.trellis function in latticeExtra, which I then update to include a title and any other desired changes, but cannot determine how to include a label for the x axis in the top plot.

##habitat amount graph
a0.Habitat<-bwplot(a0~Habitat.Amt, data =PCB.hab.dist.paramaters.sub,
par.settings = list(plot.symbol = list(pch = 2, col = "black"),col=1,box.umbrella=list(lty=1, col="black"),
box.rectangle=list(lty=1, col="black")),
ylab=list("Asymptote (a)",cex=1.5),
xlab=list("Habitat Amount (% of Landscape)", cex=1.5))

##patch graph
a0.Patches<-bwplot(a0~Patches, data =PCB.hab.dist.paramaters.sub,
par.settings = list(plot.symbol = list(pch = 2, col = "black"),col=1,box.umbrella=list(lty=1, col="black"),
box.rectangle=list(lty=1, col="black")),
ylab=list("Asymptote (a)",cex=1.5),
xlab=list("Number of Habitat Patches", cex=1.5))

####combine two graphs
combined.a0<-c( "Response_to_Fragmentation"=a0.Patches, "Response_to_Habitat_Amount"=a0.Habitat, layout=c(1,2), x.same=FALSE)

###update
update(combined.a0, main="TL Landscape", scales=list(y=list(alternating=FALSE),x=list(alternating=TRUE )))

This feels like it shoull have a really simple answer but I have been unable to find any solutions on this or other R help forums to this problem. I have attempted to not define the xlab when the initial plots are drawn and specify it at the update step, but this leads to the labels being spread across the bottom, I assume since the Update funtion is working on the plot object as a single panel. Using xlab.top to put the lable above the upper graph looks odd.

###attempt to specify 2 labels with xlab
update(combined.a0, main="TL Landscape", scales=list(y=list(alternating=FALSE),x=list(alternating=TRUE) ), xlab=c("Habitat Amount (% of Landscape)", "Patches"))

There are plenty of discussion regarding how to manipulate the scale that axis are drawn at, which is how I arrived at combining plots using latticeExtra as opposed to drawing the two plots together with the extended lattice interface which had somw quiriky behaviour in ordering factor levels across the x axis.

bwplot(a0~(Patches)+(Habitat.Amt), outer=TRUE, data=PCB.hab.dist.paramaters.sub,
par.settings = list(plot.symbol = list(pch = 2, col = "black"),col=1,
box.umbrella=list(lty=1, col="black"),box.rectangle=list(lty=1, col="black")),
ylab=list("Asymptote (a)",cex=1.5),
xlab=c("Hab", "Patches"), layout=c(1,2),scales=list(relation="free" ))

Any help would how I could either specify for the Xaxis labels of both graphs to be included when combined, or ways to specify seperate axis labels after combination would be extremely helpful.

a0 b0 c0 Index Distribution REP Habitat.Amt Patches
1 0.04914389 -0.86892828 0.0003944847 PCB 2 Patches 1 5 2
2 0.09828646 -0.86809873 0.0003945627 PCB 2 Patches 2 10 2
3 0.14743004 -0.86819141 0.0003945485 PCB 2 Patches 3 15 2
4 0.19650279 -0.87080033 0.0004640310 PCB 2 Patches 4 20 2
5 0.24562863 -0.87083379 0.0004640277 PCB 2 Patches 5 25 2
6 0.29475427 -0.87079976 0.0004640311 PCB 2 Patches 6 30 2
7 0.34321628 -0.88677178 0.0005741337 PCB 2 Patches 7 35 2
8 0.39224708 -0.88675509 0.0005741361 PCB 2 Patches 8 40 2
9 0.43964930 -0.91339697 0.0007836726 PCB 2 Patches 9 45 2
10 0.48849916 -0.91338693 0.0007836736 PCB 2 Patches 10 50 2
16 0.04822307 0.01662903 0.0004875154 PCB 4 Patches 1 5 4
17 0.09644467 0.01777045 0.0004877006 PCB 4 Patches 2 10 4
18 0.14466705 0.01821094 0.0004877409 PCB 4 Patches 3 15 4
19 0.19265015 0.01109928 0.0005715912 PCB 4 Patches 4 20 4
20 0.24081446 0.01112177 0.0005715677 PCB 4 Patches 5 25 4
21 0.28897841 0.01117924 0.0005715650 PCB 4 Patches 6 30 4
22 0.33559511 -0.01359166 0.0007090505 PCB 4 Patches 7 35 4
23 0.38114791 -0.04000038 0.0009754073 PCB 4 Patches 8 40 4
24 0.42879180 -0.04000463 0.0009754005 PCB 4 Patches 9 45 4
25 0.47643549 -0.04000530 0.0009753990 PCB 4 Patches 10 50 4
31 0.04780828 0.22108929 0.0004442073 PCB 5 Patches 1 5 5
32 0.09551991 0.22315344 0.0003972545 PCB 5 Patches 2 10 5
33 0.14323731 0.22140675 0.0003926791 PCB 5 Patches 3 15 5
34 0.19111263 0.21089745 0.0005427425 PCB 5 Patches 4 20 5
35 0.23918126 0.22255320 0.0004810829 PCB 5 Patches 5 25 5
36 0.28702280 0.22276860 0.0004810596 PCB 5 Patches 6 30 5
37 0.33432429 0.20244000 0.0005802950 PCB 5 Patches 7 35 5
38 0.38066666 0.17712990 0.0006780412 PCB 5 Patches 8 40 5
39 0.42687761 0.15966148 0.0007653099 PCB 5 Patches 9 45 5
40 0.47430651 0.15952135 0.0007652945 PCB 5 Patches 10 50 5
46 0.04692786 0.68334412 0.0005052207 PCB 9 Patches 1 5 9
47 0.09382041 0.69342727 0.0004937250 PCB 9 Patches 2 10 9
48 0.14073030 0.69065706 0.0005042077 PCB 9 Patches 3 15 9
49 0.18771848 0.68153656 0.0005905591 PCB 9 Patches 4 20 9
50 0.23465733 0.68206868 0.0005905449 PCB 9 Patches 5 25 9
51 0.28160051 0.68258821 0.0005905167 PCB 9 Patches 6 30 9
52 0.32733840 0.64959219 0.0006951437 PCB 9 Patches 7 35 9
53 0.37086396 0.60372670 0.0008839044 PCB 9 Patches 8 40 9
54 0.41724004 0.60415490 0.0008837397 PCB 9 Patches 9 45 9
55 0.46361589 0.60449739 0.0008836109 PCB 9 Patches 10 50 9