mosaicplot enhancements (PR#2023)

ligges@statistik.uni-dortmund.de ligges@statistik.uni-dortmund.de
Mon, 16 Sep 2002 11:59:52 +0200 (MET DST)


This is a feature request for mosaicplot, including the 
suggestion for the code changes (mosaicplot.R) and docs
(mosaicplot.Rd) by Wolfram Fischer and myself, 
diff'ed to 1.6.0 beta (2002-09-14):

Uwe Ligges


.../src/library/base/R/mosaicplot.R:

====================================================

11a12,13
> ### Changes by W. Fischer and U. Ligges:
> ## - Deparsing x in for main title. New arguments: sub, las, cex.axis
14,15c16,19
< function(x, main = NULL, xlab = NULL, ylab = NULL, sort = NULL, off =
<          NULL, dir = NULL, color = FALSE, shade = FALSE, margin = NULL,
---
> function(x, main = deparse(substitute(x)), sub = NULL, xlab = NULL, 
>          ylab = NULL, sort = NULL, off = NULL, dir = NULL, 
>          color = FALSE, shade = FALSE, margin = NULL, 
>          cex.axis = 0.66, las = par("las"), 
18,19c22,24
<     mosaic.cell <- function(X, x1, y1, x2, y2, off, dir, color, lablevx, lablevy,
<                             maxdim, currlev, label)
---
>     mosaic.cell <- function(X, x1, y1, x2, y2, srt.x, srt.y, 
>             adj.x, adj.y, off, dir, color, lablevx, lablevy,
>             maxdim, currlev, label)
50c55
<                      srt=0, adj=.5, cex=.66, this.lab)
---
>                      srt=srt.x, adj=adj.x, cex=cex.axis, this.lab)
110c115
<                      srt=90, adj=.5, cex=.66, this.lab)
---
>                      srt=srt.y, adj=adj.y, cex=cex.axis, this.lab)
148a154,158
> 
>     ## Calculate string rotation for different settings of las:
>     srt.x <- if(las > 1) 90 else 0
>     srt.y <- if(las == 0 || las == 3) 90 else 0
> 
301c311
<              srt = 90, cex = 0.66)
---
>              srt = 90, cex = cex.axis)
304,313c314,341
<     if (!is.null(main) || !is.null(xlab) || !is.null(ylab))
<         title(main, xlab=xlab, ylab=ylab)
< 
<     mosaic.cell(Ind,
<                 x1=50, y1=5, x2=950, y2=950,
<                 off/100, dir,
<                 color, 2, 2,
<                 maxdim= apply(as.matrix(Ind[,1:dimd]), 2, max),
<                 currlev= 1, label)
< 
---
>     if (!is.null(main) || !is.null(xlab) || !is.null(ylab) || !is.null(sub))
>         title(main, sub = sub, xlab = xlab, ylab = ylab)
>     adj.x <- adj.y <- 0.5
>     x1 <- 50; y1 <- 5; x2 <- 950; y2 <- 950
>     maxlen.xlabel <- maxlen.ylabel <- 35    
>     ## Calculations required for 'las' related string rotation 
>     ## and adjustment
>     if(srt.x == 90){
>         maxlen.xlabel <- 
>             max(strwidth(label[[dimd + 1 - match('v', rev(dir))]], 
>                 cex = cex.axis))
>         adj.x <- 1
>         y2 <- y2 - maxlen.xlabel
>     }
>     if(srt.y == 0){
>         maxlen.ylabel <- 
>             max(strwidth(label[[match('h', dir)]],
>                 cex = cex.axis))
>         adj.y <- 0
>         x1 <- x1 + maxlen.ylabel
>     }
>     
>     mosaic.cell(Ind, x1 = x1, y1 = y1, x2 = x2, y2 = y2,
>                 srt.x = srt.x, srt.y = srt.y, adj.x = adj.x, 
>                 adj.y = adj.y, off = off / 100, dir = dir, 
>                 color = color, lablevx = 2, lablevy = 2,
>                 maxdim = apply(as.matrix(Ind[,1:dimd]), 2, max),
>                 currlev = 1, label = label)

====================================================



.../src/library/base/man/mosaicplot.Rd:

====================================================

8c8,9
< \method{mosaicplot}{default}(x, main = NULL, xlab = NULL, ylab = NULL,
---
> \method{mosaicplot}{default}(x, main = deparse(substitute(x)), 
>                    sub = NULL, xlab = NULL, ylab = NULL,
10a12
>                    cex.axis = 0.66, las = par("las"),
18a21
>   \item{sub}{character string for the mosaic sub-title (at bottom).}
44a48,50
>   \item{cex.axis}{The magnification to be used for axis annotation,
>     defaults to the current multiplied by 0.66.}
>   \item{las}{numeric; the style of axis labels, see \code{\link{par}}.}

====================================================

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._