Skip to content

Latest commit

 

History

History
114 lines (76 loc) · 3.32 KB

README.md

File metadata and controls

114 lines (76 loc) · 3.32 KB

CRAN version dependencies Monthly Downloads

basetheme

R package implementing a theming system for base plotting.

Description

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.

Usage

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:
theme <- basetheme("clean")
theme$cex.main <- 2
basetheme(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.

Some Examples

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)

x <- seq(-1.95, 1.95, length = 30)
y <- seq(-1.95, 1.95, length = 35)
z <- outer(x, y, function(a, b) a*b^2)

basetheme("dark")
persp(x, y, z, theta=-45)

More Details

Additional details can be found in the Wiki pages:

  1. List of Available Themes
  2. Creating Custom Themes
  3. Installation Instructions
  4. Implementation Details

See Also

CRAN:

  1. prettyB

GitHub:

  1. styles