Re: [S] Summary for Color Table Question

Prof Brian D Ripley (ripley@stats.ox.ac.uk)
Wed, 30 Sep 1998 19:14:06 +0100 (BST)


On Wed, 30 Sep 1998 Karen_Johnson@bdhq.bd.com wrote:

> I asked, "Is there a way to set the ColorTable permanently
> or at least for the session?" (I use 4.5 with NT). Thanks to
> Steve Friedman, Bill Dunlap, and John Wallace for their help.
>
>
> The most satisfactory solution comes from Bill Dunlap.
>
> Put the following in the .First file
>
> options(default.device = expression({graphsheet();
> guiModify("GraphSheet", Name = paste("GSD",
> dev.cur(), sep = ""),
> ColorTable =
> "0,0,0|128,128,128|224,224,224|248,248,248|
> 254,30,30|232,232,17|60,60,240|255,109,21|
> 80,200,86|150,0,180|45,100,45|204,2,2|
> 255,106,163|255,175,128|234,136,255|0,0,150"
> )}))
>
> then using
>
> dev.start()
>
> to start up the new graphsheet device. (Also, if you have no
> active device and you call a graphics function then
> dev.start() is automatically called.) dev.start() evaluates
> the expression given by options("default.default") if one
> exists, otherwise it selects the default device based on what
> machine you are on.

It depends on what OS and S-PLUS version you are on (and it does not exist
in 3.x, so currently that means you get a graphsheet).

> This works for session. It seems to work for graphic windows
> opened with graphsheet() as well as dev.start() (nice, as I don't
> have to abandon pages=T and other nifty arguments that can be
> used with graphsheet()).

I do think Bill has broken part of dev.start's functionality by doing it
this way. You should be able to call dev.start() to start an appropriate
device (yes) and give it arbitrary arguments to pass on (no). To preserve
that the default.device options has to be a character string. I would have
used

options(default.device = "mygraphsheet")

mygraphsheet <- function(...) {
graphsheet(..., color.table="0,0,0|128,128,128|224,224,224|248,248,248|
254,30,30|232,232,17|60,60,240|255,109,21|
80,200,86|150,0,180|45,100,45|204,2,2|
255,106,163|255,175,128|234,136,255|0,0,150")
}

as I don't set that the separate call to guiModify is needed. Then call
mygraphsheet(args) whenever you want this color table.

[ Technical note aimed at Bill Dunlap: should dev.start not test if "name"
is a function and if so call it with argument list "args"? Then I could set
default.device to the anonymous function that is the rhs of the assignment
to mygraphsheet. ]

BTW, I keep seeing Name = paste("GSD", dev.cur(), sep = ""). In
4.5 the better way seems to me to be Name = guiGetGSName(), as I believe
I can change the name of the current graphsheet from the Layout tab or
by guiModify, and I can set the name by calling graphsheet(Name="blah").
In other words, Name = paste("GSD", dev.cur(), sep = "") will work in
Bill's expression, but not necessarily elsewhere.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

----------------------------------------------------------------------- This message was distributed by s-news@wubios.wustl.edu. To unsubscribe send e-mail to s-news-request@wubios.wustl.edu with the BODY of the message: unsubscribe s-news