Set or Get Default Palette and Image Palette RGB Values

DESCRIPTION:

Set the palette or image palette colors to specified values, or retrieve the current palette or image palette values.

USAGE:

palette(x=NULL)
image.palette(x=NULL)

OPTIONAL ARGUMENTS:

x
Character vector of color descriptions such as "red", "#FF0000", or "#FF0080". If specified, the palette or image palette will be set to this vector. If this is a single-element character vector with the value "default", the palette or image palette will be reset to the Spotfire S+ default values.

VALUE:

If x is NULL, the current palette or image palette is returned. Otherwise, the palette or image palette in place prior to changes will be returned invisibly.

SIDE EFFECTS:

If x is not NULL, the current palette or image palette will be set to the specified colors. If x is NULL, there is no side effect.

DETAILS:

The palette specifies the colors in the global color palette. This maps integer values to specific RGB values when the global color palette is being used. For example, an index of 3 is mapped to the third RGB string in the palette.

The image palette specifies the colors in the global image color palette. These are the default colors used by the image function when the global image color palette is being used.

Note that the vector names are ignored. If the colors in x have names and you wish to use them as named colors, use add.color.values to register the colors in the table of named colors.

In earlier versions of S-PLUS, a device-specific system was used to map integers to RGB values. To revert to that system, specify: use.device.palette(T).

SEE ALSO:

,

EXAMPLES:

# Get the palette and image.palette values
palette()
image.palette()

# Set the palette to 8 values generated by hsv()
palette(hsv(h=seq(0.1, 0.9, length=8), s=0.75, v=1))

# Set the image palette to 10 values generated by topo.colors()
image.palette(topo.colors(10))

# Reset the default Spotfire S+ palette and image palette
palette(splus.default.colors)
image.palette(splus.default.image.colors)

# Use add.color.values() to register the splus.default.colors
# as named colors, so we can use their names
add.color.values(splus.default.colors)
plot(1:10, col="sgreen")

# Set the palette and image palette to match R
rcolors <- x11.colors[c("black", "red", "green3", "blue", "cyan",
  "magenta", "yellow", "gray")]
palette(rcolors)
image.palette(heat.colors(12))

# Another way to reset to the defaults
palette("default")
image.palette("default")