[R] Changing grid defaults

Brett Presnell presnell at stat.ufl.edu
Mon Apr 9 03:48:46 CEST 2012


First I'd like to thank Ilaik and Paul for their responses.

I seem to be getting what I need by using LaTeX's tikz package and
including tikz=true in the options for the figure chunks using vcd,
e.g.,

<<fig=true,tikz=true,width=5,height=5,echo=FALSE,results=hide>>=
... R commands ...
@

I have actually used this before in other documents, but not for this
purpose, so it didn't occurred to me to try it until Ilaik mentioned
tikz in his message.

FTR, I never could get successfully change the color defaults for grid,
at least not for vcd graphics (again, this is easy to do for traditional
R graphics in Sweave).  In particular, when I took Paul's suggestion and
added the line

pushViewport(viewport(gp=gpar(col="yellow")))

before the graphics command, I got no output, which didn't surprise me
too much.  Adding a popViewport() command produced an error message:

  Cannot pop the top-level viewport (grid and graphics output mixed?)

I wasn't able to see how to get what I needed using the font commands in
the article that Paul pointed to either, and I don't have time to pursue
it any further right now.  So I'm going to cut and run, and hope that
the tikz approach will work out.

Still, it would be nice (for me at least) if there was a full example
somewhere showing how to change the grid defaults (foreground and
background colors in particular) in an Sweave document in such a way
that they stay changed throughout the document, particularly in a
document that also uses traditional R graphics.



More information about the R-help mailing list