[This article was first published on rapporter, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
R has a great variety of plotting tools (just to mention a few: the base graphics and e.g. lattice and ggplot2 packages building on grid) and most R user has a preference for either of them.
I think all of you would agree with me: each package has its advantages and also disadvantages compared to the others. And any senior R user could compile a lengthy list about this topic. But we do not intend to start a flame-war here 🙂
So I do not share my personal preferences in this post despite the fact that I was really puzzled while developing pander: which graphics package should be supported with configurable options? As I planned to provide some panderOptions in which the user could specify e.g. a color palette or the font family to be used in all of his plots. But which library is used by most of R users? And how many potential users would I loose by choosing that only one?
In short, I decided to support all major graph engines, which means letting users specify their custom options and apply those to all graphics, lattice and ggplot2 calls. This decision was a fast and promising one, the development was rather cumbersome.
I came up with the idea to tweak evals further and apply options while evaluating R commands. This solution has the advantage of also tweaking e.g. par before the actual commands (and even the plotting functions of graphics too), but evals got even more bloated. Well, I decided to take that trouble.
Now we have a bunch of optionsavailable if graph.unify is enabled in evalsOptions (disabled by default not to freak out newcomers). You can fine-tune (panderOptions) the foreground, background and other color palettes, the global font size and even the font family used, the grid with optional minor ticks (even in base plots), the legend position and the angle of axis labels besides some other small tweaks.
I will only concentrate on the results below to keep this post short, if you would be interested in the sources, please check out the relevant branch on GitHub.
To show a brief demo of the new options, let us load the package and enable graph.unify for evals:
library(pander) evalsOptions('graph.unify', TRUE)
First, let us check out how a default histogram looks like in the major graphics packages applied to horsepower in mtcars: