Jens Hainmueller
2004-Sep-15 13:24 UTC
[R] control of font size & colour for title, subtitles, axis, and tick marks in LATTICE graph
Hi, I very much appreciate any help on this "fine tuning" problem in a lattice graph (I am new to LATTICE and could not find an example in the help files that worked for me. My apologies if I missed it there). I am running the following box plots to compare conditional distributions of x at different levels of y under two treatment conditions ID=1 (upper panel ) & ID=0 (lower panel of the plot). bwplot(HF.ELECYEAR ~ stparvotech | ID , data=data, aspect=1, layout=c(1,2), xlab="Changes in Party Vote Shares", xlim=(-20:20), ylab="Periods Following Last Federal Election", main="Divided Government", panel = function(x,y) { panel.bwplot(x,y) panel.abline(v=0, col="red") } ) How can I: 1. Control the font size of the main title, the panel titles, the axis, and the tick marks? The usual cex.main=1/3, cex.xlab etc. do not work. 2. Change the color of the boxes where the panel titles (ID=1 & ID=0) are located? Thank you very much. Best, Jens
Deepayan Sarkar
2004-Sep-15 14:47 UTC
[R] control of font size & colour for title, subtitles, axis, and tick marks in LATTICE graph
On Wednesday 15 September 2004 08:24, Jens Hainmueller wrote:> Hi, > > I very much appreciate any help on this "fine tuning" problem in a > lattice graph (I am new to LATTICE and could not find an example in > the help files that worked for me. My apologies if I missed it > there).Well, if the examples were to cover all possible uses, there would be so many that they would become practically useless as reference. You are also expected to read the documentation. At least for your first question, the solution is described pretty much where you would expect it to be (see below).> I am running the following box plots to compare conditional > distributions of x at different levels of y under two treatment > conditions ID=1 (upper panel ) & ID=0 (lower panel of the plot). > > bwplot(HF.ELECYEAR ~ stparvotech | ID , > data=data, aspect=1, > layout=c(1,2), > xlab="Changes in Party Vote Shares", > xlim=(-20:20), > ylab="Periods Following Last Federal Election", > main="Divided Government", > panel = function(x,y) > { > panel.bwplot(x,y) > panel.abline(v=0, col="red") > } > ) > > How can I: > 1. Control the font size of the main title, the panel titles, the > axis, and the tick marks? The usual cex.main=1/3, cex.xlab etc. do > not work.Why do you expect them to? In help(bwplot), the entry for 'main' says: main: character string or expression or list describing main title to be placed on top of each page. Defaults to 'NULL'. Can be a character string or expression, or a list with components 'label, cex, col, font'. The 'label' tag can be omitted if it is the first element of the list. Expressions are treated as specification of LaTeX-like markup as in 'plotmath' which suggests that main = list(label = "Divided Government", cex = 1/3) is what you want.> 2. Change the color of the boxes where the panel titles > (ID=1 & ID=0) are located?See help(strip.default). You need to use something like strip = function(..., bg) strip.default(..., bg = "white") (The next version of lattice will have a slightly easier way to do this, along with an example.) All this can also be done by changing the settings globally (see help(trellis.par.get)), but that's probably not what you want. Hope that helps, Deepayan