@@ -64,11 +64,6 @@ RedGrayBlue <- colorRampPalette(c("firebrick", "lightgray", "#375997"))
6464# ' To correctly outline the split-plot factor, simply concatenate the
6565# ' whole-plot factor and sub-plot factor together.
6666# '
67- # ' To get a map of a field with a true aspect ratio (lattice version only),
68- # ' include 'aspect=ylen/xlen'
69- # ' in the call, where 'ylen' is the vertical length of the field and 'xlen'
70- # ' is the horizontal length of the field.
71- # '
7267# ' To call this function inside another function, you can hack like this:
7368# ' vr <- "yield"; vx <- "x"; vy <- "y";
7469# ' eval(parse(text=paste("desplot(", vr, "~", vx, "*", vy, ", data=yates.oats)")))
@@ -153,6 +148,13 @@ RedGrayBlue <- colorRampPalette(c("firebrick", "lightgray", "#375997"))
153148# ' @param cex Expansion factor for text/number in each cell.
154149# '
155150# ' @param strip.cex Strip cex.
151+ # '
152+ # ' @param aspect Aspect ratio.
153+ # ' To get a map of a field with a true aspect ratio include 'aspect=ylen/xlen'.
154+ # ' For lattice, 'ylen' is the vertical length of the field and 'xlen'
155+ # ' is the horizontal length of the field.
156+ # ' For ggplot2, 'ylen' is the vertical length of each cell/plot and 'xlen'
157+ # ' is the horizontal length of each plot.
156158# '
157159# ' @param subset An expression that evaluates to logical index vector for subsetting the data.
158160# '
@@ -189,11 +191,18 @@ RedGrayBlue <- colorRampPalette(c("firebrick", "lightgray", "#375997"))
189191# ' d1 <- update(d1, par.settings = list(layout.heights=list(strip=2)))
190192# ' print(d1)
191193# '
192- # ' # Show experiment layout
193194# ' data(yates.oats)
195+ # ' # Show experiment layout in true aspect
196+ # ' # Field width = 4 plots * 44 links = 176 links
197+ # ' # Field length = 18 plots * 28.4 links = 511 links
198+ # ' # With lattice, the aspect ratio is y/x for the entire field
194199# ' desplot(yates.oats,
195200# ' yield ~ col+row,
196- # ' out1=block, out2=gen)
201+ # ' out1=block, out2=gen, aspect=511/176)
202+ # ' # With ggplot, the aspect ratio is y/x for each cell
203+ # ' ggdesplot(yates.oats,
204+ # ' yield ~ col+row,
205+ # ' out1=block, out2=gen, aspect=28.4/44)
197206# '
198207# ' desplot(yates.oats,
199208# ' block ~ col+row,
@@ -219,7 +228,8 @@ desplot <- function(data,
219228 show.key = TRUE ,
220229 key.cex , # left legend cex
221230 cex = .4 , # cell cex
222- strip.cex = .75 ,
231+ strip.cex = .75 ,
232+ aspect = NULL ,
223233 subset = TRUE , gg = FALSE , ... ){
224234
225235 # Would be nice to remove this code someday, maybe 2022?
0 commit comments