[R] inconsistent behavior in bxp as compared to most plots

Martin Maechler maechler at stat.math.ethz.ch
Fri Sep 15 18:23:38 CEST 2000


>>>>> "Uwe" == Uwe Ligges <ligges at statistik.uni-dortmund.de> writes:

    Uwe> "Ritter, Christian C SRTCL-CTGAS" wrote:
    >>  It took me a little while to trace this back ...
    >> 
    >> bxp from R1.1.0 does not use xaxt or yaxt but only axes.

    Uwe> Try: par(xaxt="n")
    Uwe>      bxp(.....)


    Uwe> If you want to change the behavior of bxp(.), have a look into the
    Uwe> last lines of that function:

    ...

well, actually looking at  bxp() reveals that  bxp(*, axes=*)  cannot work
either... {whoever moved that line "pars <- list(pars, ...)" into the local
	   function instead of bxp() itself.....}
I've added xaxt,yaxt, and "frame.plot" functionality and re-instated
axes and ylim ...
			--> all for "R-devel" (aka unstable 1.2)

Here is the patch if you want:

--- R-1.1.1/src/library/base/R/boxplot.R 	Wed Jun 21 18:20:44 2000
+++ R-devel/src/library/base/R/boxplot.R	Fri Sep 15 17:56:23 2000
@@ -95,13 +96,14 @@
 bxp <- function(z, notch=FALSE, width=NULL, varwidth=FALSE,
 	        notch.frac = 0.5, boxwex = 0.8,
 		border=par("fg"), col=NULL, log="", pars=NULL,
+                frame.plot = axes,
 		 ...)
 {
+    pars <- c(pars, list(...))
+
     bplt <- function(x, wid, stats, out, conf, notch, border, col)
     {
-	## Draw single box plot.
-	pars <- c(pars, list(...))# from bxp(...).
-
+	## Draw single box plot
 	if(!any(is.na(stats))) {
 	    ## stats = +/- Inf:	 polygon & segments should handle
 	    wid <- wid/2
@@ -140,7 +142,7 @@
     ## just for compatibility with S
     if(is.null(z$out))   z$out   <- vector(length=0)
     if(is.null(z$group)) z$group <- vector(length=0)
-    if((comp.ylim <- is.null(pars$ylim)))
+    if(is.null(pars$ylim))
         ylim <- range(z$stats[is.finite(z$stats)],
                       z$out  [is.finite(z$out)],
                       if(notch)
@@ -177,10 +179,11 @@
     axes <- is.null(pars$axes)
     if(!axes) { axes <- pars$axes; pars$axes <- NULL }
     if(axes) {
-	if(n > 1) axis(1, at=1:n, labels=z$names)
-	axis(2)
+	if(n > 1) axis(1, at=1:n, labels=z$names, xaxt = pars$xaxt)
+	axis(2, yaxt = pars$yaxt)
     }
     do.call("title", pars)
+    if(frame.plot)
     box()
     invisible(1:n)
 }
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list