Skip to content
Themes for base plotting system in R
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
man
DESCRIPTION
NAMESPACE
README.md

README.md

basetheme

R package implementing a theming system for base plotting.

Description

The basetheme() function provides a way to set and unset R plotting settings.

Themes

Demonstration using:

pairs(iris[,1:4], col=iris$Species)
legend("bottom", legend=unique(iris$Species), col=unique(iris$Species),
       pch=par("pch"), cex=0.8, horiz=TRUE, bty="n", inset=c(0,1), xpd=TRUE
       )

default

basetheme("clean")

clean

basetheme("brutal")

brutal

basetheme("ink")

ink

basetheme("dark")

dark

basetheme("minimal")

minimal

basetheme("void")

void

Usage

Everything is done by calling the basetheme() function. There are 4 different modes:

  1. Choosing a theme by name
basetheme("clean")
  1. Specifying a list with theme values
theme <- basetheme_clean()
basetheme(theme)
  1. Specifying the values directly
basetheme(pch=19, bg="blue")
  1. Removing the current theme
basetheme(NULL)
  1. Obtaining list of theme parametrs
# current theme
basetheme()
# specified theme
theme <- basetheme("clean")

Additional parameters can be specified everytime. For example if you like a theme (say "minimal") but would like to change a few parameters:

basetheme("minimal", bg="grey", pch=1)

Creating a Theme

Simplest way is to obtain a default list of values and change them.

Here is an example of creating a grey-ish sheme:

pars <- basetheme("default")
pars$palette <- c("black", grey.colors(8))  # numbered colors - shades of grey
pars$bg  <- "white"                         # some colors
pars$fg  <- "gray20"                        # some colors
pars$col <- "gray20"                        # some colors
pars$col.main <- "black"                    # some colors
pars$col.axis <- "gray20"                   # some colors
pars$col.lab  <- "gray20"                   # some colors
pars$family   <-  "mono"                    # change font
pars$lab      <-  c(10,10,7)                # more ticks on axes
pars$cex.axis <-  0.8                       # smaller axis labels
pars$las      <-  1                         # always horizontal axis labels
pars$rect.border <- "black"                 # box around the plot
pars$rect.lwd    <- 4                       # ticker border

basetheme(pars)

barplot(1:9, col=1:9, names=LETTERS[1:9], main="barplot", ylab="heights")

ex9

Installation

Using devtools library:

devtools::install_github("KKPMW/basetheme")

Details

Under the hood this library utilizes two hooks that are implemented in the plot.new() function: before.plot.new and plot.new.

You can’t perform that action at this time.