Learn R Programming

lessR (version 2.6)

set: Set the Default Color Theme and Other System Settings

Description

Each graph is based on a default color theme. The original default is colors="blue", but set allows other color palettes to be set as default as well. Setting ghost=TRUE provides transparency effects against a black background. Other system settings are also available.

Usage

set(colors=c("blue", "gray", "rose", "green", "gold", "red",
                  "orange", "dodgerblue", "purple"),

col.fill.bar=NULL, trans.fill.bar=NULL, col.fill.pt=NULL, trans.fill.pt=NULL, col.stroke.bar=NULL, col.stroke.pt=NULL, col.bg=NULL, col.grid=NULL, col.heat=NULL, ghost=NULL,

n.cat=4, width=120, show=FALSE)

Arguments

colors
The specified color scheme.
col.fill.bar
Color of a filled region, such as a histogram bar.
trans.fill.bar
The transparency of a filled bar or rectangular region, such as a histogram bar or the box in a box plot. Value from 0 to 1, opaque to transparent.
col.fill.pt
Color of a filled region, such as a plotted point.
trans.fill.pt
The transparency of the inner region of a plotted point. Value from 0 to 1, opaque to transparent.
col.stroke.bar
Color of the border of a filled region such as a histogram bar.
col.stroke.pt
Color of a line or outline of a filled region, such as the border of a plotted point.
col.bg
Color of the plot background.
col.grid
Color of the grid lines.
col.heat
Color of the heat map for correlation matrices.
ghost
Add a black background, transparent gridlines and transparency for the bars. Overrides individual settings for those values.
n.cat
Number of categories, which specifies the largest number of unique values of variable of a numeric data type for which the variable will be analyzed as categorical. Set to 0 to turn off.
width
Maximum width of each line displayed at the console, just accesses the standard R options function for width.
show
Option for showing all settings.

Details

Sets the default color palette via the R options statement, as well as the transparency of plotted bars and points. Each time colors is reset, the specific color options are reset to their default values, which includes a transparency fill for plotted points of 0.66.

The gray color scheme is based on the colors used in Hadley Wickham's ggplot2 package.

Set ghost=TRUE is equivalent to setting col.bg to "black" and col.grid to "transparent" with a bar transparency of 0.7. It overides these settings individually, so must turn ghost=FALSE and set each of the three settings individually to change from the standard ghost settings.

References

Wickham, Hadley, ggplot2: Elegant Graphics for Data Analysis, 2nd edition, Springer, 2009.

See Also

options.

Examples

Run this code
# set all subsequent graphic output to gray scale
set(colors="gray")

# define a custom color theme: sienna
# this works regardless of the set color theme because
#   all of the individual components of the theme are changed
# the trans options are the default values, so not necessary to
#   set unless already changed previously
# the three ghost settings - trans.fill.bar, col.grid and col.bg --
#   must be manually entered to achieve  a ghost plot
set(col.fill.bar="sienna3")
set(col.fill.pt="sienna3")
set(col.stroke.bar="sienna3")
set(col.stroke.pt="sienna4")
set(col.bg="seashell1")
set(col.grid="seashell2")
set(trans.fill.bar=.00)
set(trans.fill.pt=.66)

# all numeric variables with 8 or less unique values are analyzed
#   as categorical variables
set(n.cat=8)

Run the code above in your browser using DataLab