Richard M. Heiberger
2011-Jun-02 03:59 UTC
[R] ylab spacing in resizePanels in latticeExtra
I would like the ylab in the second, resized graph to be centered on the actual positions of the panels of the second graph, not on the positions appropriate for the first graph. How can that be specified. Toggle the two graphs to see that the ylab is identically spaced in both, even though the panels are differently sized. Thanks, Rich windows.options(record=TRUE) ## We need to compare two graphs. This is the correct statement for windows. require(lattice) require(latticeExtra) A <- barchart(matrix(1:10,5,2)) B <- barchart(matrix(1:6,3,2)) C <- barchart(matrix(1:8,4,2)) ABC <- c(A, B, C, x.same=TRUE, layout=c(1,3)) ABCu <- update(ABC, ylab=list(c("AAA", "BBB", "CCC"), rot=0)) update(ABCu, main="ylab is centered on each of the panels") ABCur <- resizePanels(ABCu, h=c(5,3,4)) update(ABCur, main="ylab is centered on previous panel positions.") [[alternative HTML version deleted]]
Indeed, ylab position is not connected to the panel size / position. You would have to place them manually... ## scaling factors on panels h <- c(5,3,4) update(ABCur, ylab = list(c("AAA", "BBB", "CCC"), rot=0, y = (cumsum(h) - h/2) / sum(h) )) Cheers Felix On 2 June 2011 13:59, Richard M. Heiberger <rmh at temple.edu> wrote:> I would like the ylab in the second, resized graph to be centered on the > actual positions of the panels > of the second graph, not on the positions appropriate for the first graph. > How can that be specified. > Toggle the two graphs to see that the ylab is identically spaced in both, > even though the panels are > differently sized. > > Thanks, > > Rich > > > windows.options(record=TRUE) ## We need to compare two graphs. ?This is the > correct statement for windows. > > require(lattice) > require(latticeExtra) > > A <- barchart(matrix(1:10,5,2)) > B <- barchart(matrix(1:6,3,2)) > C <- barchart(matrix(1:8,4,2)) > ABC <- c(A, B, C, x.same=TRUE, layout=c(1,3)) > > ABCu <- update(ABC, > ? ? ? ? ? ? ? ylab=list(c("AAA", "BBB", "CCC"), rot=0)) > update(ABCu, main="ylab is centered on each of the panels") > > ABCur <- resizePanels(ABCu, > ? ? ? ? ? ? ? ? ? ? ?h=c(5,3,4)) > update(ABCur, main="ylab is centered on previous panel positions.") > > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Felix Andrews / ??? http://www.neurofractal.org/felix/