[R] mult.fig() utility [was "margin text mtext"]

Bill.Venables@CMIS.CSIRO.AU Bill.Venables at CMIS.CSIRO.AU
Mon Jun 11 09:46:02 CEST 2001


I have an objection in principle to anything that has the side-effect of
clobbering something in the global environment, even something as innocuous
looking as "old.par".  I certainly object to putting something like that
into a public library, however clever and useful the code might be.  It just
is not safe.

As a quick way round this I suggest the following (R only) solution:

1. Give the function mult.fig an explicit local environment on definition:

> environment(mult.fig) <- new.env()

2. Instead of using the superassignment operator, assign the restore list to
the local environment of multi.fig (from within multi.fig):

	 assign("old.par", ......, envir = environment(mult.fig))

3. Provide a special argument to mult.fig so that instead of using
par(old.par) to restore the original graphics parameters the user does
something like

> mult.fig(restore = TRUE)

Honour is satisfied.

(The S solution would be to call it .old.par and to put it in frame 0.)


The other suggestion you make is putting things like plotCI into some sort
of miscellaneous graphics function library.  Not a bad idea, but may I
suggest that plotCI should be re-written so that there is a generic
function, say CI(), that does the setup and calculations and generates an
object of class "CI", which is plotted by the method plot.CI for the plot
generic?  I think this is a better way of handling it (again in principle).

I find to my surprise that I am quoted as the original author of plotCI but
I don't think I am.  I think all I did was to modify and extend something
even more ancient that I seem to recall came from Charles Geyer.  We are
talking long, long ago now, though...

Bill Venables.

-----Original Message-----
From: Martin Maechler [mailto:maechler at stat.math.ethz.ch]
Sent: Monday, 11 June 2001 4:55 PM
To: R-help at stat.math.ethz.ch
Cc: Christian Hoffmann
Subject: [R] mult.fig() utility [was "margin text mtext"]

Now that this is solved...
The task of setting up a multi-figure plot with a title
(and "fixing" mar a bit) is such a common thing that I had designed a
utility function for the job, ``back in the time of S-plus'' ;-)
and called it  mult.fig().

I (and few people here) have been using it for several years now
and it may be that it'd be worth to be put into one of those ``misc''
packages {{maybe we should rename ``stepfun'' to ``graphmisc'' and
	   add a few things, including the "plotCI" one?}}

Anyway here is the code and the doc:

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