Learn R Programming

lessR (version 3.6.2)

style: Set the Default Color Theme and Other System Settings

Description

Deprecated Names: set, theme

The color and style attributes of each plot can be individually set from the following list of attributes. For convenience, groups of these attributes are specified to define color themes, plus style sub-themes that apply to any theme, with default values: theme="lighbronze" and sub.theme="default".

Usage

style(
  theme=c("lightbronze", "darkred", "dodgerblue", "gray", "gold",
        "darkgreen", "blue", "red", "rose", "green", "purple", "sienna",
        "brown", "orange", "white"),
  sub.theme=c("default", "black", "no.y.axis"),

device.fill=getOption("device.fill"), bg.fill=getOption("bg.fill"), bg.stroke=getOption("bg.stroke"), bg.lwd=getOption("bg.lwd"), bg.lty=getOption("bg.lty"),

fill=NULL, bar.fill=getOption("bar.fill"), pt.fill=getOption("pt.fill"), trans=NULL, trans.bar.fill=getOption("trans.bar.fill"), trans.pt.fill=getOption("trans.pt.fill"), stroke=NULL, bar.stroke=getOption("bar.stroke"), pt.stroke=getOption("pt.stroke"), se.fill=getOption("se.fill"), ellipse.fill=getOption("ellipse.fill"), bubble.fill=getOption("bubble.fill"), bubble.text.stroke=getOption("bubble.text.stroke"), heat=getOption("heat"),

cex.axis=getOption("cex.axis"), axis.x.stroke=getOption("axis.x.stroke"), axis.y.stroke=getOption("axis.y.stroke"), values.stroke=getOption("values.stroke"), rotate.x=getOption("rotate.x"), rotate.y=getOption("rotate.y"), offset=getOption("offset"),

grid.stroke=NULL, grid.x.stroke=getOption("grid.x.stroke"), grid.y.stroke=getOption("grid.y.stroke"), grid.lwd=getOption("grid.lwd"), grid.lty=getOption("grid.lty"), lab.stroke=getOption("lab.stroke"), lab.size=getOption("lab.size"), main.stroke=getOption("main.stroke"), segment.stroke=getOption("segment.stroke"),

add.stroke=getOption("add.stroke"), add.cex=getOption("add.cex"), add.lwd=getOption("add.lwd"), add.lty=getOption("add.lty"), add.fill=getOption("pt.fill"),

n.cat=getOption("n.cat"), suggest=getOption("suggest"), 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

theme

The specified color scheme. If specified, re-sets all style attributes to their start-up values.

sub.theme

Further modification of the main themes.

device.fill

Fill color of the entire device window.

bg.fill

Color of the plot background.

bg.stroke

Color of border around the plot background, the box, that encloses the plot, with a default of "black".

bg.lwd

Line width of the box around the plot.

bg.lty

Line type of the box around the plot: "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash", or "blank".

fill

Color of a filled region, both bars and points.

bar.fill

Color of a filled region, such as a histogram bar.

pt.fill

Color of a filled region, such as a plotted point.

trans

Transparency of a filled bar or rectangular region and points.

trans.bar.fill

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.

trans.pt.fill

The transparency of the inner region of a plotted point. Value from 0 to 1, opaque to transparent.

stroke

Color of a stroke, a line such as the border of bar or point.

bar.stroke

Color of the border of a filled region such as a histogram bar.

pt.stroke

Color of a line or outline of a filled region, such as the border of a plotted point.

se.fill

Color of the fill for the standard error plot about a fit line in a scatter plot.

ellipse.fill

Color of the fill for an ellipse in a scatter plot.

bubble.fill

Fill color of bubbles.

bubble.text.stroke

Color of bubble text.

heat

Color of the heat map for correlation matrices.

cex.axis

Scale magnification factor, which by defaults displays the axis values to be smaller than the axis labels. Provides the functionality of, and can be replaced by, the standard R cex.axis.

axis.x.stroke

Color of the x-axis.

axis.y.stroke

Color of the y-axis.

values.stroke

Color of the font used to label the axis values.

rotate.x

Degrees that the x-axis values are rotated, usually to accommodate longer values, typically used in conjunction with offset.

rotate.y

Degrees that the y-axis values are rotated.

offset

The spacing between the axis values and the axis. Default is 0.5. Larger values such as 1.0 are used to create space for the label when longer axis value names are rotated.

grid.stroke

Color of the grid lines.

grid.x.stroke

Color of the grid lines for the x-axis.

grid.y.stroke

Color of the grid lines for the y-axis.

grid.lwd

Width of grid lines.

grid.lty

Line type for grid lines: "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash", or "blank".

lab.stroke

Color of the axis labels.

lab.size

Size of labels for x and y axes.

main.stroke

Color of the title.

segment.stroke

Color of line segments.

add.stroke

Color of added text.

add.cex

Size of added text.

add.lwd

Line width of added lines.

add.lty

Line type of added lines.

add.fill

Fill color of added rectangles.

n.cat

Number of categories that specifies the largest number of unique equally-spaced values of variable of a numeric data type for which the variable will be analyzed as categorical. Applies to ScatterPlot and SummaryStats, and also to the functions such as Histogram when processing multiple graphs.

suggest

If TRUE, then provide suggestions for alternative analyses.

quiet

If TRUE then some functions suppress console output.

brief

If set to TRUE, reduced text output.

results

For the R markdown file generated by the Rmd option, show the results.

explain

For the R markdown file generated by the Rmd option, explain the results.

interpret

For the R markdown file generated by the Rmd option, interpret the results.

document

For the R markdown file generated by the Rmd option, documents the code that generated the results.

code

For the R markdown file generated by the Rmd 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

OVERVIEW Sets the default color palette via the R options statement, as well as the transparency of plotted bars and points and other non-color characteristics such as the color of the grid lines. For convenience, groups of attributes are organized into themes and sub-themes. When theme is specified, all options are reset to their default values. All other modifications, with individual parameters or grouped parameters as a sub-theme, are cumulative. For example, one sub-theme can be followed by another, as well as the specifications of individual attributes.

The "gray" color theme is based on the colors used in Hadley Wickham's ggplot2 package. The "lightbronze" theme, especially with the no.y.axis sub-theme, is based on Jeffrey Arnold's wsj theme from his ggthemes package.

SUB-THEMES "black": Black background of the entire device window witth translucent fill colors from the current theme. "no.y.axis": Similar to the wsj theme from the ggthemes package, especially with the theme of "lightbronze". The y-axis is removed with though the value labels retained, the vertical grid is removed, and the horizontal grid is dotted and thicker than the default.

References

Arnold, Jeffrey B., (2017), ggthemes: Extra Themes, Scales and Geoms for 'ggplot2'. R package version 3.4.0. https://CRAN.R-project.org/package=ggthemes

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

See Also

options.

Examples

Run this code
# NOT RUN {
# some data
mydata <- rd("Employee", format="lessR", quiet=TRUE)

# gold colors embedded in a black background
style("gold", sub.theme="black")
Plot(Years, Salary, size=0, ellipse=seq(.1,.9,.1))

# four ways to go gray scale
# 1. remove the light bronze background from default lightbronze theme,
#    which otherwise displays only in gray scale
style(device.fill="white")
# 2. gray scale with a light gray background
style("gray")
# 3. gray scale with a dark, almost black, background
style("gray", sub.theme="black")
# 4. mostly black and white
style("white")

# define a custom style beyond just colors
style(bg.fill="off", bg.stroke="off",
      device.fill=rgb(247,242,230, maxColorValue=255),
      pt.fill="black", trans=0,
      lab.stroke="black", values.stroke="black",
      axis.y.stroke="off",
      grid.x.stroke="off", grid.y.stroke="black",  grid.lty="dotted", grid.lwd=1)
hs(Salary)


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

Run the code above in your browser using DataLab