Deprecated Names: set
, theme
The color and style attributes of each plot can be set as a general theme, or 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="lightbronze"
and sub.theme="default"
. To reset to the default theme: style()
.
style(
theme=c("colors", "lightbronze", "dodgerblue", "darkred", "gray",
"gold", "darkgreen", "blue", "red", "rose", "green", "purple",
"sienna", "brown", "orange", "white"),
sub.theme=c("default", "black", "no.y.axis"),
set=NULL, get=TRUE, window.fill=getOption("window.fill"),
panel.fill=getOption("panel.fill"),
panel.color=getOption("panel.color"),
panel.lwd=getOption("panel.lwd"),
panel.lty=getOption("panel.lty"),
fill=NULL,
bar.fill=getOption("bar.fill"),
bar.fill.discrete=getOption("bar.fill.discrete"),
bar.fill.ordered=getOption("bar.fill.ordered"),
trans=NULL,
trans.bar.fill=getOption("trans.bar.fill"),
color=NULL,
bar.color=getOption("bar.color"),
bar.color.ordered=getOption("bar.color.ordered"),
bar.color.discrete=getOption("bar.color.discrete"),
values=getOption("values"),
values.color=getOption("values.color"),
values.cex=getOption("values.cex"),
values.digits=getOption("values.digits"),
values.pos=getOption("values.pos"),
pt.fill=getOption("pt.fill"),
trans.pt.fill=getOption("trans.pt.fill"),
pt.color=getOption("pt.color"),
se.fill=getOption("se.fill"),
ellipse.fill=getOption("ellipse.fill"),
ellipse.color=getOption("ellipse.color"),
ellipse.lwd=getOption("ellipse.lwd"),
fit.color=getOption("fit.color"),
fit.lwd=getOption("fit.lwd"),
bubble.text.color=getOption("bubble.text.color"),
heat=getOption("heat"),
segment.color=getOption("segment.color"),
ID.color=getOption("ID.color"),
area.fill=getOption("area.fill"),
out.fill=getOption("out.fill"),
out.color=getOption("out.color"),
out2.fill=getOption("out2.fill"),
out2.color=getOption("out2.color"),
violin.fill=getOption("violin.fill"),
violin.color=getOption("violin.color"),
box.fill=getOption("box.fill"),
box.color=getOption("box.color"),
axis.color=getOption("axis.color"),
axis.x.color=getOption("axis.x.color"),
axis.y.color=getOption("axis.y.color"),
axis.lwd=getOption("axis.lwd"),
axis.x.lwd=getOption("axis.x.lwd"),
axis.y.lwd=getOption("axis.y.lwd"),
axis.lty=getOption("axis.lty"),
axis.x.lty=getOption("axis.x.lty"),
axis.y.lty=getOption("axis.y.lty"),
axis.cex=getOption("axis.cex"),
axis.x.cex=getOption("axis.x.cex"),
axis.y.cex=getOption("axis.y.cex"),
axis.text.color=getOption("axis.text.color"),
axis.x.text.color=getOption("axis.x.text.color"),
axis.y.text.color=getOption("axis.y.text.color"),
rotate.x=getOption("rotate.x"),
rotate.y=getOption("rotate.y"),
offset=getOption("offset"),
lab.color=getOption("lab.color"),
lab.x.color=getOption("lab.x.color"),
lab.y.color=getOption("lab.y.color"),
lab.cex=getOption("lab.cex"),
lab.x.cex=getOption("lab.x.cex"),
lab.y.cex=getOption("lab.y.cex"),
main.color=getOption("main.color"),
main.cex=getOption("main.cex"),
grid.color=getOption("grid.color"),
grid.x.color=getOption("grid.x.color"),
grid.y.color=getOption("grid.y.color"),
grid.lwd=getOption("grid.lwd"),
grid.x.lwd=getOption("grid.x.lwd"),
grid.y.lwd=getOption("grid.y.lwd"),
grid.lty=getOption("grid.lty"),
grid.x.lty=getOption("grid.x.lty"),
grid.y.lty=getOption("grid.y.lty"),
strip.fill=getOption("strip.fill"),
strip.color=getOption("strip.color"),
strip.text.color=getOption("strip.text.color"),
add.fill=getOption("add.fill"),
add.trans=getOption("add.trans"),
add.color=getOption("add.color"),
add.cex=getOption("add.cex"),
add.lwd=getOption("add.lwd"),
add.lty=getOption("add.lty"),
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(…)
The specified color scheme. If specified, re-sets all style attributes to the values consistent with that theme.
Further modification of the main themes.
A list of parameter values, a theme, that was previously saved, and now is read back to become the current set of parameter values. See the examples.
Save the current list of parameter values, a theme, into an R object.
Fill color of the entire device window.
Color of the plot background.
Color of border around the plot background, the box, that
encloses the plot, with a default of "black"
.
Line width of the box around the plot.
Line type of the box around the plot. Acceptable values are
"blank"
, "solid"
, "dashed"
, "dotted"
,
"dotdash"
, and "longdash"
.
Color of a filled region -- bars, points and bubbles --
depending on the
objected plotted. Can explicitly choose "grays"
or "colors"
, or pre-specified R color schemes
"rainbow"
, "terrain"
, and "heat"
. Can also
provide pre-defined color ranges "blues"
, "reds"
and "greens"
, as well as
custom colors, such as generated by getColors
Color of a filled bar, bubble or box.
Color of a filled bar chart bar or pie chart slice.
Color of a filled histogram bar.
Transparency of a filled bar, rectangular region, or points from 0 (none) to 1 (complete).
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.
Color of a line segment such as the border of bar or point.
Can explicitly choose "grays"
or "colors"
, or pre-specified R color schemes
"rainbow"
, "terrain"
, and "heat"
. Can also
provide pre-defined color ranges "blues"
, "reds"
and "greens"
, as well as
custom colors, such as generated by getColors
Color of the border of a filled region such as a histogram bar.
Color of the border of a filled region for values on a qualitative scale.
Color of the border of a filled region for values on a quantitative scale, such as a histogram bar.
If not the default value of "off"
, adds the
numerical results to the plot according to "%"
,
"prop"
or "input"
, that is, percentages,
proportions, or the value from which the slices are plotted,
such as tabulated counts if y
is not specified,
or the value of y
if the plotted values are provided. If
any other values
parameter is specified, default is set
to "%"
.
Color of the plotted text. Could be a vector to specify a unique color for each value. If fewer colors are specified than the number of categories, the colors are recycled.
Character expansion factor, the size, of the plotted text, for which the default value is 0.95.
Number of decimal digits for which to display the values.
Default is 0, round to the nearest integer, for "%"
and 2 for "prop"
.
Position of the plotted text. Default is inside the pie,
or, if "label"
, as part of the label for each value
outside of the pie.
Color of a filled plotted point.
The transparency of the inner region of a plotted point. Value from 0 to 1, opaque to transparent.
Color of a line or outline of a filled region, such as the border of a plotted point.
Color of the fill for the standard error plot about a fit line in a scatter plot.
Color of the fill for an ellipse in a scatter plot.
Color of the border for an ellipse in a scatter plot.
Line width of the border for an ellipse in a scatter plot.
Color of the fit line in a scatter plot.
Width of fit line. By default is 2 for Windows and 1.5 for Mac.
Color of the displayed text regarding the size of a bubble,
either a tabulated frequency for categorical variables, or the value of a
third variable according to size
.
Color of the heat map for correlation matrices.
Color of connecting line segments when there are also plotted
points, such as in a frequency polygon. Default color is color
.
Color of the text to display the ID labels.
Fill color of the area under a line in a run chart or time series.
For a scatterplot, color of the border of potential outliers, which, for the unadjusted boxplot, are default values 1.5 IQR's beyond the lower or upper quartile.
For a scatterplot, color of potential outliers.
For a scatterplot, color of extreme outliers, which, for the unadjusted boxplot, are default values 3 IQR's beyond the lower or upper quartile.
For a scatterplot, color of the border of extreme outliers.
Fill color for a violin plot, applicable to a 1-variable scatter plot of a continuous variable.
Border color for the "violin" in a violin plot.
Fill color for a box plot, part of a violin plot, applicable to a 1-variable scatter plot of a continuous variable.
Border color of a box in a box plot.
Color of the axes.
Color of the x
-axis.
Color of the y
-axis.
Line width of axes.
Line width of horizontal axis.
Line width of vertical axis.
Line type of axes, either "solid", "dashed", "dotted", "dotdash", "longdash", "twodash", or "blank".
Line type of horizontal axis.
Line type of vertical 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
.
Scale magnification factor for the x
-axis.
Scale magnification factor for the y
-axis.
Color of the font used to label the axis values.
Color of the font used to label the x
-axis values.
Color of the font used to label the y
-axis values.
Degrees that the x
-axis values are rotated, usually to
accommodate longer values, typically used in conjunction with offset
.
Degrees that the y
-axis values are rotated.
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.
Color of the axis labels.
Color of the axis labels on the horizontal axis.
Color of the axis labels on the vertical axis.
Size of labels for x and y axes.
Size of labels for x.
Size of labels for y.
Color of the title.
Size of the title font.
Color of the grid lines.
Color of the grid lines for the x
-axis.
Color of the grid lines for the y
-axis.
Width of grid lines.
Width of vertical grid lines, inherits from grid.lwd
.
Width of horizontal grid lines, inherits from grid.lwd
.
Line type for grid lines: "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash", or "blank".
Line-type of vertical grid lines, inherits from grid.lty
.
Line-type of horizontal grid lines, inherits from grid.lty
.
Fill color for the strip that labels each panel in a Trellis plot.
Border color for the strip that labels each panel in a Trellis plot.
Color of the label in each strip of a Trellis plot.
Interior fill color of added object.
Can explicitly choose "grays"
or "colors"
, or pre-specified R color schemes
"rainbow"
, "terrain"
, and "heat"
. Can also
provide pre-defined color ranges "blues"
, "reds"
and "greens"
, as well as
custom colors, such as generated by getColors
Transparency level of color or fill, which ever is applicable from 0 (opaque) to 1 (transparent).
Color of borders and lines of added object.
Text expansion factor, relative to 1. As with the following properties, can be a vector for multiple placement or objects.
Line width of added object.
Line type of added object. See panel.lty
for types.
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.
If TRUE
, then provide suggestions for alternative analyses.
If TRUE
then some functions suppress console output.
If set to TRUE
, reduced text output.
For the R markdown file generated by the Rmd option, show the results.
For the R markdown file generated by the Rmd option, explain the results.
For the R markdown file generated by the Rmd option, interpret the results.
For the R markdown file generated by the Rmd option, documents the code that generated the results.
For the R markdown file generated by the Rmd option, shows the code that generated the results.
Maximum width of each line displayed at the console, just accesses the standard R options function for width.
Option for showing all settings.
Parameter values.
The current settings can optionally be saved into an R
object, and then read back at a later time with the set
function..
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 the 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. Calling the function with no arguments sets to the default style.
Available themes:
"lightbronze" [default]
"dodgerblue" [default lessR
3.6.0 and earlier]
"darkred"
"gray"
"gold"
"darkgreen"
"blue"
"red"
"rose"
"green"
"purple"
"sienna"
"brown"
"orange"
"white"
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 with 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.
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.
# NOT RUN {
# some data
mydata <- rd("Employee", in.lessR=TRUE, quiet=TRUE)
# gold colors embedded in a black background
style("gold", sub.theme="black")
Plot(Years, Salary, size=0, ellipse=seq(.1,.9,.1))
# three ways to do gray scale
style(window.fill="white")
# 1. gray scale with a light gray background
style("gray")
# 2. gray scale with a dark, almost black, background
style("gray", sub.theme="black")
# 3. mostly black and white
style("white")
# reset style to the default "colors"
style()
# set bar fill to qualitative hcl colors
# here also turn off bar borders and set to a mild transparency
Histogram(Salary, fill="greens", color="off")
# same as
# style(bar.fill.ordered="greens", bar.color="off")
# Histogram(Salary)
# set bar fill to 6 blue colors
# for continuous band explicitly call getColors and specify n
# to obtain the full spectrum, such as for analysis of Likert
# scale responses with six possible responses per item
style(bar.fill=getColors("blues", n=6))
# adjust Trellis strip to a dark background
style(strip.fill="gray60", strip.color="gray20",
strip.text.color=rgb(247,242,230, maxColorValue=255))
Plot(Years, Salary, by1=Gender)
# define a custom style beyond just colors
style(panel.fill="off", panel.color="off",
window.fill=rgb(247,242,230, maxColorValue=255),
pt.fill="black", trans=0,
lab.color="black", axis.text.color="black",
axis.y.color="off",
grid.x.color="off", grid.y.color="black", grid.lty="dotted", grid.lwd=1)
hs(Salary)
# save the current theme settings into an R object without changes
# unless set to FALSE, get is always TRUE, for all calls to style
mystyle <- style(get=TRUE)
# ... bunch of changes
# then recall older settings to current theme setting
style(set=mystyle)
# create a gray-scale with a sub-theme of no.y.axis
# save, and then at a later session read back in
grayWSJ <- style("gray", sub.theme="no.y.axis")
Write("grayWSJ", data=grayWSJ, format="R")
# ...
mystyle <- Read("grayWSJ.rda") # read grayWSJ.rda
style(set=mystyle)
# 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