[R] xyplot lattice fine control of axes limits and thick marks (with log scale)

maxbre mbressan at arpa.veneto.it
Thu Mar 29 11:04:23 CEST 2012


Elai

Ok, this is my reproducible example

tm<-structure(list(name_short = structure(1:29, .Label = c("D4", 
"D5", "D6a", "D6b", "D6c", "D7", "D8", "F4", "F5a", "F5b", "F6a", 
"F6b", "F6c", "F6d", "F7a", "F7b", "F8", "P105", "P114", "P118", 
"P123", "P126", "P156", "P157", "P167", "P169", "P189", "P77", 
"P81"), class = "factor"), sub_family = structure(c(3L, 3L, 3L, 
3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L, 1L, 
1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 2L, 2L), .Label = c("pcb mono-ortho subs", 
"pcb non-ortho subs", "pcdd", "pcdf"), class = "factor"), tv = c(1.069, 
6.461, 5.461, 12.764, 10.86, 117.912, 256.875, 452.204, 124.02, 
327.856, 88.469, 61.539, 17.794, 84.117, 121.668, 13.414, 68.409, 
3023.333, 428, 19454.667, 151.333, 324, 11478.667, 1220.667, 
5335.333, 124.667, 1542.667, 594.667, 193.333), ms = c(1.787, 
4.831, 3.456, 14.105, 10.808, 116.02, 296.957, 30.533, 21.821, 
32.969, 33.767, 29.799, 12.812, 49.637, 126.522, 17.522, 106.087, 
1787.5, 130, 6751.5, 81, 23, 370, 33.5, 147.5, 5.406, 18.5, 415, 
69.906)), .Names = c("name_short", "sub_family", "tv", "ms"), class =
"data.frame", row.names = c(NA, 
-29L))

and this is my code

#start 
library(lattice)
library(latticeExtra)

xyplot(tv ~ ms | sub_family, data=tm,
       #as.table=TRUE,
       aspect="xy",
       xlab = expression(paste('ms [ fg/', m^3, ' ]', sep = '')),
       ylab = expression(paste('tv [ fg/', m^3, ' ]', sep = '')),
       scales= list(x=list(relation="free", log=10, cex=0.8),
                    y=list(relation="free", log=10, cex=0.8)),
       
       prepanel = function(x, y, subscripts) {
         list(xlim = c(min(x,y), max(x,y)))
         list(ylim= c(min(x,y), max(x,y)))
       },
       
       panel = function(x, y ,subscripts,...) {
         panel.xyplot(x, y, cex=0.8,...)
         panel.abline(a = 0, b = 1, lty = 2, col ="gray")
         panel.text(x, y, labels=tm$name_short[subscripts], cex = 0.8,
pos=3, offset=0.5, srt=0, adj=c(1,1))
       },
       
       subscripts=TRUE,
       xscale.components = xscale.components.logpower,
       yscale.components = yscale.components.logpower
       )

#end

And here in attachment is the graphic output
http://r.789695.n4.nabble.com/file/n4514868/output.png output.png 

To answer your question:
- I did not put relation=’same’ because that is not what I want: i.e **for
each single panel** (in my case 4) I want to set the same limits for both x
and y axes (I want the diagonal line exactly bisect each panel); see what
happen by putting relation=’same’…(I do not want to group the panels by a
single x and y axes)
- I need to set the same number of thick arks for both x and y axes *of each
panel*, but with log scale it’s quite tricky at least seems so to myself)

Thanks for your help

max


--
View this message in context: http://r.789695.n4.nabble.com/xyplot-lattice-fine-control-of-axes-limits-and-thick-marks-with-log-scale-tp4511897p4514868.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list