R package implementing a theming system for base plotting.
The basetheme()
function provides a
persistent way to set and unset R plotting settings.
All the user has to do is set the theme once and it will be consistently
applied to all the subsequent plots even after the graphics device is
closed. The function only works with base graphics system, so if you are
exclusively working with ggplot2
, boy, did you install the
wrong package.
The persistent settings are controlled via the
basetheme()
function. To an extent this function mimics the
behaviour and arguments of par()
and has multiple modes of
operation:
# Specifying the `par()` values directly:
basetheme(pch=19, mgp=c(2,.7,0), tck=-.01)
# Choosing a theme by name:
basetheme("clean")
# Using a mix of the above:
basetheme("minimal", bg="grey", pch=1)
# Specifying a list with theme values:
<- basetheme("clean")
theme $cex.main <- 2
themebasetheme(theme)
# Obtaining a list of parameters for the current theme:
basetheme()
# Removing the current theme:
basetheme(NULL)
In addition to basetheme()
two additional functions are
provided for colors manipulation within the plots:
num2col()
and lab2col()
. See documentation:
help(basetheme)
, help(num2col)
,
help(lab2col)
and examples:
example(basetheme)
, example(num2col)
,
example(lab2col)
for more details.
A few examples using of how it all works together.
basetheme("void")
boxplot(split(iris$Sepal.Width, iris$Species))
basetheme("clean")
barplot(rivers, col=num2col(rivers))
basetheme("brutal")
plot(hclust(dist(USArrests), "ward.D2"), hang=-1)
basetheme("royal")
pairs(iris[-5], bg=lab2col(iris$Species), col=0)
basetheme("deepblue")
pairs(iris[-5], bg=num2col(iris[,1]), col=0)
<- seq(-1.95, 1.95, length = 30)
x <- seq(-1.95, 1.95, length = 35)
y <- outer(x, y, function(a, b) a*b^2)
z
basetheme("dark")
persp(x, y, z, theta=-45)
Additional details can be found in the Wiki pages:
CRAN:
GitHub: