Learn R Programming

lessR (version 3.4.6)

theme: Set the Default Color Theme and Other System Settings

Description

Deprecated Name: set

Each graph is based on a default color theme. The original default is colors="dodgerblue", but theme 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

theme(colors=c("blue", "gray", "rose", "green", "gold", "red",
         "dodgerblue", "purple", "sienna", "orange.black",
         "gray.black", "white"),

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=getOption("n.cat"), lab.size=getOption("lab.size"), quiet=getOption("quiet"), brief=getOption("brief"),

results=getOption("results"), explain=getOption("explain"), interpret=getOption("interpret"), document=getOption("document"), code=getOption("code"),

width=120, show=FALSE)

set(...)

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
If TRUE, add a black background, transparent grid lines and transparency for the bars. Overrides individual settings for those values. Setting to FALSE has no effect.
n.cat
Number of categories that specifies the largest number of unique equall-spaced values of variable of a numeric data type for which the variable will be analyzed as categorical. Applies to S
lab.size
Size of labels for x and y axes.
quiet
If TRUE then some functions suppress console output.
brief
If set to TRUE, reduced text output. Can change system default with theme function.
results
For the R markdown file generated by the knitr.file option, show the results.
explain
For the R markdown file generated by the knitr.file option, explain the results.
interpret
For the R markdown file generated by the knitr.file option, interpret the results.
document
For the R markdown file generated by the knitr.file option, documents the code that generated the results.
code
For the R markdown file generated by the knitr.file option, shows the code that generated the results.
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.
...
Parameter values.

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 overrides 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
theme(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
theme(col.fill.bar="seagreen3")
theme(col.fill.pt="seagreen3")
theme(col.stroke.bar="seagreen4")
theme(col.stroke.pt="seagreen4")
theme(col.bg="seashell1")
theme(col.grid="seashell2")
theme(trans.fill.bar=.00)
theme(trans.fill.pt=.66)

# all numeric variables with 8 or less unique values and equally spaced
#  intervals are analyzed as categorical variables
theme(n.cat=8)

Run the code above in your browser using DataLab