[R] Retaining X axis labels when combining lattice graphs

Bevan bevan.ernst at gmail.com
Thu Oct 18 04:41:46 CEST 2012


Hi Duncan, 

Thanks for taking the time to look at my problem.  I apologize for sending
in my data in an improper format, I have included the dput output for my
data at the bottom of this message.  I guess I was not clear on the exact
problem I was trying to solve.  I want to keep each trellis object
(ao.Habitat, and a0.patches, I've attached jpegs of how they are produced
when I execute my script) as they are with a0 as function of each variable
with vertical boxplotswith a0 on the y axis and the values of habitat amount
or patch numebr on the x axis.  I run into trouble when I try to combine the
two objects into a single plot stacked vertically to export them to a
manuscript.  When I combine them 
<http://r.789695.n4.nabble.com/file/n4646563/a0_Habitat.jpeg> 
<http://r.789695.n4.nabble.com/file/n4646563/a0_Patches.jpeg> 
##
combined.a0<-c( "Response_to_Fragmentation"=a0.Patches,
"Response_to_Habitat_Amount"=a0.Habitat, recursive=FALSE, layout=c(1,2),
x.same=FALSE)
##
so that I can assign a common title etc... only the label for the x axis on
the lower is visible (see the attached combined__a0.jpg).  The only thing I
am trying to do is make the label axis for the top graph to be displayed as
it is in the initial a0.Habitat boxplot.  I can orient the plots
horizontally (layout=c(2,1) vs, layout(1,2) and manipulate the x axis in
that layout but that doesn't work well with how I want to display the data. 
I can ways export them as seperate graphs and manipulate and do my layout in
the word processor, it just seems like there should be a way to do it in R
before export.  
<http://r.789695.n4.nabble.com/file/n4646563/combined_ao.jpeg> 

I hope my problem is more clear with this explanation and the images I
included (provided they display correctly, I am posting to the email list
through the nabble interface).  Thanks again for taking the time to look at
my problem.

Bevan 




structure(list(a0 = c(0.0491438864815412, 0.0982864594455828, 
0.147430042423261, 0.19650279353983, 0.245628630467369, 0.294754267218032, 
0.343216281539003, 0.39224707834672, 0.439649299456975, 0.488499162052381, 
0.0482230731682795, 0.0964446686774879, 0.144667050430179,
0.192650149287812, 
0.240814455350727, 0.288978406881119, 0.33559510691696, 0.381147909161427, 
0.428791801595536, 0.476435492541546, 0.0478082776216181,
0.0955199141921243, 
0.143237311433409, 0.191112632579508, 0.239181262412026, 0.287022795974056, 
0.334324294458928, 0.380666664220398, 0.42687760867532, 0.474306509551676, 
0.0469278629252043, 0.0938204068729251, 0.140730301246147,
0.187718476356652, 
0.234657327784517, 0.281600508176611, 0.327338397412457, 0.37086396474747, 
0.417240035718929, 0.463615885076853), b0 = c(-0.868928278369896, 
-0.868098733112605, -0.868191407278176, -0.87080033347661,
-0.870833789858265, 
-0.870799764600649, -0.886771775012127, -0.88675508558289,
-0.913396965839612, 
-0.913386927069418, 0.0166290252812099, 0.0177704530943037,
0.0182109370128824, 
0.0110992762930325, 0.0111217733302857, 0.0111792393893794,
-0.0135916621637894, 
-0.0400003772893172, -0.0400046344842489, -0.0400052998576042, 
0.22108928544134, 0.223153436547079, 0.221406752334103, 0.210897449031587, 
0.222553199225228, 0.222768597329309, 0.202439998834243, 0.17712990407219, 
0.159661475004338, 0.159521354607916, 0.683344121653545, 0.693427266932841, 
0.690657059653011, 0.681536558009155, 0.682068683227174, 0.68258821313661, 
0.649592193910639, 0.603726702275101, 0.60415489745892, 0.604497388218304
), c0 = c(0.000394484738338566, 0.000394562678940318, 0.000394548527915422, 
0.000464030997468826, 0.000464027660887953, 0.000464031115391004, 
0.000574133650986739, 0.00057413610459678, 0.00078367257958205, 
0.000783673551729415, 0.000487515401215572, 0.000487700627255601, 
0.000487740904053134, 0.000571591186814001, 0.000571567735405171, 
0.000571565047985638, 0.00070905048169047, 0.000975407332155666, 
0.000975400469000318, 0.000975399031401637, 0.000444207318665042, 
0.000397254474508407, 0.000392679125715812, 0.000542742503904821, 
0.000481082873497068, 0.000481059628662438, 0.000580294957185582, 
0.000678041195534257, 0.000765309915164961, 0.000765294532447683, 
0.000505220719692491, 0.000493725010184687, 0.000504207708422164, 
0.000590559144440146, 0.000590544938788768, 0.000590516696893918, 
0.000695143703211527, 0.000883904379524948, 0.000883739703900095, 
0.000883610946652792), Index = c("PCB", "PCB", "PCB", "PCB", 
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", 
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", 
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", 
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB"
), Distribution = c("2 Patches", "2 Patches", "2 Patches", "2 Patches", 
"2 Patches", "2 Patches", "2 Patches", "2 Patches", "2 Patches", 
"2 Patches", "4 Patches", "4 Patches", "4 Patches", "4 Patches", 
"4 Patches", "4 Patches", "4 Patches", "4 Patches", "4 Patches", 
"4 Patches", "5 Patches", "5 Patches", "5 Patches", "5 Patches", 
"5 Patches", "5 Patches", "5 Patches", "5 Patches", "5 Patches", 
"5 Patches", "9 Patches", "9 Patches", "9 Patches", "9 Patches", 
"9 Patches", "9 Patches", "9 Patches", "9 Patches", "9 Patches", 
"9 Patches"), REP = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 
4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 
4, 5, 6, 7, 8, 9, 10), Habitat.Amt = structure(c(1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 
4L, 5L, 6L, 7L, 8L, 9L, 10L), .Label = c("5", "10", "15", "20", 
"25", "30", "35", "40", "45", "50"), class = "factor"), Patches =
structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("2", "4", "5", "9"), class =
"factor")), .Names = c("a0", 
"b0", "c0", "Index", "Distribution", "REP", "Habitat.Amt", "Patches"
), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 16L, 
17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 31L, 32L, 33L, 34L, 
35L, 36L, 37L, 38L, 39L, 40L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 
53L, 54L, 55L), class = "data.frame")
> test<-structure(list(a0 = c(0.0491438864815412, 0.0982864594455828, 
+                       0.147430042423261, 0.19650279353983,
0.245628630467369, 0.294754267218032, 
+                       0.343216281539003, 0.39224707834672,
0.439649299456975, 0.488499162052381, 
+                       0.0482230731682795, 0.0964446686774879,
0.144667050430179, 0.192650149287812, 
+                       0.240814455350727, 0.288978406881119,
0.33559510691696, 0.381147909161427, 
+                       0.428791801595536, 0.476435492541546,
0.0478082776216181, 0.0955199141921243, 
+                       0.143237311433409, 0.191112632579508,
0.239181262412026, 0.287022795974056, 
+                       0.334324294458928, 0.380666664220398,
0.42687760867532, 0.474306509551676, 
+                       0.0469278629252043, 0.0938204068729251,
0.140730301246147, 0.187718476356652, 
+                       0.234657327784517, 0.281600508176611,
0.327338397412457, 0.37086396474747, 
+                       0.417240035718929, 0.463615885076853), b0 =
c(-0.868928278369896, 
+                                                                    
-0.868098733112605, -0.868191407278176, -0.87080033347661,
-0.870833789858265, 
+                                                                    
-0.870799764600649, -0.886771775012127, -0.88675508558289,
-0.913396965839612, 
+                                                                    
-0.913386927069418, 0.0166290252812099, 0.0177704530943037,
0.0182109370128824, 
+                                                                    
0.0110992762930325, 0.0111217733302857, 0.0111792393893794,
-0.0135916621637894, 
+                                                                    
-0.0400003772893172, -0.0400046344842489, -0.0400052998576042, 
+                                                                    
0.22108928544134, 0.223153436547079, 0.221406752334103, 0.210897449031587, 
+                                                                    
0.222553199225228, 0.222768597329309, 0.202439998834243, 0.17712990407219, 
+                                                                    
0.159661475004338, 0.159521354607916, 0.683344121653545, 0.693427266932841, 
+                                                                    
0.690657059653011, 0.681536558009155, 0.682068683227174, 0.68258821313661, 
+                                                                    
0.649592193910639, 0.603726702275101, 0.60415489745892, 0.604497388218304
+                       ), c0 = c(0.000394484738338566,
0.000394562678940318, 0.000394548527915422, 
+                                 0.000464030997468826,
0.000464027660887953, 0.000464031115391004, 
+                                 0.000574133650986739, 0.00057413610459678,
0.00078367257958205, 
+                                 0.000783673551729415,
0.000487515401215572, 0.000487700627255601, 
+                                 0.000487740904053134,
0.000571591186814001, 0.000571567735405171, 
+                                 0.000571565047985638, 0.00070905048169047,
0.000975407332155666, 
+                                 0.000975400469000318,
0.000975399031401637, 0.000444207318665042, 
+                                 0.000397254474508407,
0.000392679125715812, 0.000542742503904821, 
+                                 0.000481082873497068,
0.000481059628662438, 0.000580294957185582, 
+                                 0.000678041195534257,
0.000765309915164961, 0.000765294532447683, 
+                                 0.000505220719692491,
0.000493725010184687, 0.000504207708422164, 
+                                 0.000590559144440146,
0.000590544938788768, 0.000590516696893918, 
+                                 0.000695143703211527,
0.000883904379524948, 0.000883739703900095, 
+                                 0.000883610946652792), Index = c("PCB",
"PCB", "PCB", "PCB", 
+                                                                  "PCB",
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", 
+                                                                  "PCB",
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", 
+                                                                  "PCB",
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", 
+                                                                  "PCB",
"PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB", "PCB"
+                                 ), Distribution = c("2 Patches", "2
Patches", "2 Patches", "2 Patches", 
+                                                     "2 Patches", "2
Patches", "2 Patches", "2 Patches", "2 Patches", 
+                                                     "2 Patches", "4
Patches", "4 Patches", "4 Patches", "4 Patches", 
+                                                     "4 Patches", "4
Patches", "4 Patches", "4 Patches", "4 Patches", 
+                                                     "4 Patches", "5
Patches", "5 Patches", "5 Patches", "5 Patches", 
+                                                     "5 Patches", "5
Patches", "5 Patches", "5 Patches", "5 Patches", 
+                                                     "5 Patches", "9
Patches", "9 Patches", "9 Patches", "9 Patches", 
+                                                     "9 Patches", "9
Patches", "9 Patches", "9 Patches", "9 Patches", 
+                                                     "9 Patches"), REP =
c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 
+                                                                          
4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 
+                                                                          
4, 5, 6, 7, 8, 9, 10), Habitat.Amt = structure(c(1L, 2L, 3L, 
+                                                                                                                           
4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
+                                                                                                                           
9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 
+                                                                                                                           
4L, 5L, 6L, 7L, 8L, 9L, 10L), .Label = c("5", "10", "15", "20", 
+                                                                                                                                                                    
"25", "30", "35", "40", "45", "50"), class = "factor"), Patches =
structure(c(1L, 
+                                                                                                                                                                                                                                                  
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
+                                                                                                                                                                                                                                                  
2L, 2L, 2L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 
+                                                                                                                                                                                                                                                  
4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("2", "4", "5", "9"), class =
"factor")), .Names = c("a0", 
+                                                                                                                                                                                                                                                                                                                                              
"b0", "c0", "Index", "Distribution", "REP", "Habitat.Amt", "Patches"
+                                                                                                                                                                                                                                                  
), row.names = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 16L, 
+                                                                                                                                                                                                                                                                   
17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 31L, 32L, 33L, 34L, 
+                                                                                                                                                                                                                                                                   
35L, 36L, 37L, 38L, 39L, 40L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 
+                                                                                                                                                                                                                                                                   
53L, 54L, 55L), class = "data.frame")



--
View this message in context: http://r.789695.n4.nabble.com/Retaining-X-axis-labels-when-combining-lattice-graphs-tp4646514p4646563.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list