[R] graphical paramters to boxplot --> patch

Martin Maechler maechler at stat.math.ethz.ch
Mon Jan 25 14:43:28 CET 1999


>>>>> "MM" == Martin Maechler <maechler at stat.math.ethz.ch> writes:

>>>>> "Lorenz" == Lorenz Gygax <lgygax at access.unizh.ch> writes:
    Lorenz> Dear all, is this a bug or do a miss something (this concerns
    Lorenz> version 0.63.1 on Linux)?

    MM> Thank you Lorenz, for reporting it.  It is indeed a minor bug (a
    MM> wrong warning).

    >>> boxplot (c (1, 2, 3, 4, 5), ylim= c (-5, 5))
    Lorenz> Warning: parameter "ylim" couldn't be set in high-level plot()
    Lorenz> function
    >>> boxplot (c (1, 2, 3, 4, 5), pars= list (ylim= c (-5, 5)))
    Lorenz> Warning: parameter "ylim" couldn't be set in high-level plot()
    Lorenz> function

    MM> both of these are equivalent.

    Lorenz> and actually in both cases ylim is set as I want it to be.

    MM> yes.

    MM> Looking at boxplot(), one realizes quickly that the warning is
    MM> produced within bxp(), actually when do.call("title",pars) happens
    MM> (at that time, pars shouldn't contain ylim anymore...).

    MM> Since this is only a small nuisance, I'll not post the patch once I
    MM> have it. However, this should go into the release-patches
    MM> shortly...

It was too easy, and the patch is short enough, even for R-help, I hope:


--- boxplot.R.~1~	Sat Nov 14 16:08:00 1998
+++ boxplot.R	Mon Jan 25 14:37:57 1999
@@ -108,7 +108,8 @@
     else if (n == 1) 0.4
     else rep(0.8, n)
 
-    ylim <- if(is.null(pars$ylim)) limits else pars$ylim
+    if(is.null(pars$ylim)) ylim <- limits
+    else { ylim <- pars$ylim; pars$ylim <- NULL }
     if(missing(border) || length(border)==0)
 	border <- par("fg")
 
@@ -124,7 +125,9 @@
 	     border=border[(i-1)%%length(border)+1],
 	     col=if(is.null(col)) col else col[(i-1)%%length(col)+1])
 
-    if(is.null(pars$axes) || pars$axes) {
+    axes <- is.null(pars$axes)
+    if(!axes) { axes <- pars$axes; pars$axes <- NULL }
+    if(axes) {
 	if(n > 1) axis(1, at=1:n, labels=names(z))
 	axis(2)
     }
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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