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 consistenlty applied to all the subsequent plots. Even after the graphics device is closed.
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
)
Everything is done by calling the basetheme()
function. There are 4 different modes:
Additional parameters can be specified everytime. For example if you like a theme (say “minimal”) but would like to change a few parameters:
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")
From CRAN:
Using devtools library:
To install the developement version (stable updates not yet on CRAN):
Under the hood this library utilizes two hooks that are implemented in the plot.new()
function: before.plot.new
and plot.new
.
CRAN:
GitHub: