Hi


Jari Oksanen wrote:
On Wed, 2004-10-27 at 10:04, Uwe Ligges wrote:

Robin Hankin wrote:


Hello list.

I very often need 3d scatterplots, and use scatterplot3D quite a lot.
I am trying to modify persp() to plot scatterplots, and make use of
the theta and phi arguments that persp() offers.  I am having some
difficulty passing the correct arguments to persp().

Here is my function so far.  Much of it is copied from the persp() manpage.
work as expected, but all extra arguments are passed to persp() _and_
lines() and this gives warnings.

---cut---


QUESTION:

What is best practice to handle this sort of problem?  Should I ignore
the warnings() that this approach gives?  I can suppress them with
options(warn= -Inf), but is this a good idea?  I've read section 10.4
of AITR.

Many of us have thought about this problem.
I'd suggest to introduce frequently used arguments to your meta-function (such as main, xlab, ylab, ...), but ignore warnings (note: warnings, not errors) if less frequently arguments are passed through "...".


Alternatively, you can exclude "..." from lines() or points() and specify a list of arguments to be passed to that call.


This is a larger problem if 1. one of the underlying functions does not have "..."
2. you want to relay arguments to two or more underlying functions, and
3. you don't want to list all possible arguments in your function
definition, since it is long enough already.


4. you want to only relay arguments a, b, and c to one function and only c and d to another function. For example, plot.default() only passes the col argument on to plot.xy() (not to axes or title).

5. arguments can have quite different meanings when passed to different functions. e.g., col means fill colour when passed to rect(), but border colour when passed to box().

This all leads to argument lists like that for plot.default(); you make many par arguments formal arguments (with sensible defaults!) and explicitly control which functions they get relayed on to.

In your particular case, I think the best approach is to explicitly provide a bunch of arguments (with defaults) that might get passed to persp(), pass them to persp() and pass them plus everything else (...) to points().

Paul

p.s. main, xlab, and ylab are not graphical parameters (as in par()) so I think they should definitely be formals of your points3d()


The solution is still there, but it is (black) magic. For instance,
'arrows' does not have "...", so you must add them with this magical
mystery string:

formals(arrows) <- c(formals(arrows), alist(... = ))

Yes, this is documented in R manuals -- I wouldn't know this otherwise.
Still, it would be nicer if 'arrows' had "..."...

cheers, jari oksanen


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to