Paul Roebuck <roebuck@odin.mdacc.tmc.edu> wrote:
> How can I programmatically define a color scheme?
Here's a function to open a Motif window which displays and prints in your
chosen color scheme. The trick is to send the same information to Motif (via
"xrm") and to ps.options (via the "color" argument). I've provided a default
9-color scheme, but you can pass your own colors, as long as they: 1) are
dimnames of ps.colors.rgb, and 2) contain no spaces. I've assumed an
environment variable "COL_PRINTER".
.colors <- function(color=T, printer=getenv("COL_PRINTER")) {
if (color[1]==T) color <- c("black", "red", "green", "blue", "cyan",
"magenta", "yellow", "purple", "orange")
ps.options(tempfile="splot##.ps", colors=ps.colors.rgb[color, ], horiz=T,
command=paste("lpr -P", printer, sep=""))
if (dev.cur() > 1) dev.off()
xrm <- c("-xrm 'sgraphMotif*defaultFont: 0'", "-geometry 520x464+0+0",
paste("-xrm 'sgraphMotif*colorSchemes: name: Dflt;",
"background: white; lines:", paste(color, collapse=" "), "'"))
motif(xrm)
}
-- David Brahm (brahm@alum.mit.edu)
|