A templating scheme for R
This is supposed to develop into an R package. But for now it is just a collection of code and ideas.
The function template()
is designed to create a list of parameters that will be used to overwrite the default settings in R. The returned objects have the class template
.
The call par(template)
will replace the default settings with the parameters stored in the template
object for this session of R. The call also takes an argument journal
which is a template object that is treated with higher priority and overwrites all set parameters. A database of journal objects will be distributed with the package.
a call of par(default)
will restore all initial settings of R. There are some discussion threats on the internet about that 1, 2
All high-level and low-level plotting functions should therefore adopt the parameters that were set.
Additional low-level functions might be provided as well, such as a label()
function that allows adding text including TeX equations.
The lattice package and the ggplot2 package both seem to provide themes, standardised styles for the graphics. However Lattice is made for complex layout arrangements of multivariate, stacked data plots. ggplot2 follows this tradition. The packages both provide help for arranging data and plotting them in a visually attractive and comprehensible way. Similar is true for the package grid, which seems to be basic but provides some quite powerful functions for arrangement and modification of plots.
To complement those established packages, our package should be really minimalistic and only support the default plotting functions. We do not meddle with the scatterplot or barplot. We just teach them how to have a consistent look and feel.
The package needs to make changes in the following places to reach all plotting devices:
The problem I encountered is that the par is reset to default each time a new window/plotting device is called. How to change the default?
I guess what we need is to collect a list of all possible graphical parameters for all devices and then redistribute the parameters stored in the template to those places.
Rgraphics.pdf by Thomas Girke
grid by Paul Murell
I found this interesting post on how to merge lists.