Changing fonts in main title of plot in R

1k views Asked by At

I am using Sweave and knitr together with <<dev="tikz">>= for figures. For simplicity, I first will try to explain my problem without providing a minimal working example:

I am using the command acf for plotting an autocorrelation function and want to change the font of the main title to e.g. font.main=1. I looked up the documentation which tells me that additional arguments of acf are the same as for plot.acf, which in turn uses the same as plot. Therefore I think font.main should work for acf as good as it does for plot. Unfortunately, adding an additional parameter for font.main in acf has no effect on the font of the main title. However, in plot this works fine. What is wrong here?

1

There are 1 answers

1
Edward On BEST ANSWER

Something seems odd because the documentation of acf states that ... are "further arguments to be passed to plot.acf". And, the documentation of plot.acf further states that ... are "graphics parameters to be passed to the plotting routines".

This seems partially correct as passing font.lab and font.axis appear to produce the intended effect. However, font.main is ignored for reasons yet to be uncovered.

Until this gets fixed, the solution is to change the graphical parameters first, then run the command.

op <- par(font.main=1, ...)
acf(...)
par(op) # change back