Re: [R] Changing grid defaults

2012-04-08 Thread Brett Presnell

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.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Changing grid defaults

2012-04-06 Thread ilai
You might want to check out package {tikzDevice} and it's
documentation. In essence you turn your R plots to tikz-pgf so they
can be naturally incorporated into a beamer presentation. Colors, bg,
fonts etc. can now be controlled in your main latex doc. I find it
much more convenient, and nicer when the plot annotations make use of
the same latex font rather than e.g. plotmath. Note, for grid graphics
you'll need to use print(yourplot) to the device.

Cheers

On Fri, Apr 6, 2012 at 8:43 AM, Brett Presnell presn...@stat.ufl.edu wrote:

 I'm trying to use the vcd package to produce mosaic plots for my class
 notes, written in Sweave and using the LaTeX's beamer document class.
 For projecting the notes in class, I use a dark background with light
 foreground colors.  It's easy enough to change the defaults for R's
 standard graphics to match my color scheme (using the fg, col.axis,
 col.lab, col.main, and col.sub parameter settings), but I can't figure
 out how to do this with grid/strucplot/vcd.

 From my experiments, I think that I might eventually figure out how to
 change the colors of all the text in the mosaic plots to what I want
 using arguments like 'gp_args = list(gp_labels = gpar(col = yellow)'
 and 'gp_varnames = gpar(col = yellow)' (although I still haven't
 figured out how to changed the color of the text on the legends), but
 this is obviously not what I need.  I have been reading all the
 documentation I can find, but I still haven't figured this out, so an
 answer accompanied by a reference to some line or the other in some
 piece of documentation would be greatly appreciated.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Changing grid defaults

2012-04-06 Thread Paul Murrell

Hi

On 7/04/2012 2:43 a.m., Brett Presnell wrote:


I'm trying to use the vcd package to produce mosaic plots for my class
notes, written in Sweave and using the LaTeX's beamer document class.
For projecting the notes in class, I use a dark background with light
foreground colors.  It's easy enough to change the defaults for R's
standard graphics to match my color scheme (using the fg, col.axis,
col.lab, col.main, and col.sub parameter settings), but I can't figure
out how to do this with grid/strucplot/vcd.


From my experiments, I think that I might eventually figure out how to

change the colors of all the text in the mosaic plots to what I want
using arguments like 'gp_args = list(gp_labels = gpar(col = yellow)'
and 'gp_varnames = gpar(col = yellow)' (although I still haven't
figured out how to changed the color of the text on the legends), but
this is obviously not what I need.  I have been reading all the
documentation I can find, but I still haven't figured this out, so an
answer accompanied by a reference to some line or the other in some
piece of documentation would be greatly appreciated.


You could push a 'grid' viewport with the desired defaults and then 
hopefully 'vcd' will pick those up as its defaults.  The following 
example promises at least partial (if ugly) success ...


library(vcd)
pushViewport(viewport(gp=gpar(col=yellow)))
mosaic(Titanic, newpage=FALSE)

You can similarly set up font defaults.  See Non-standard fonts in 
PostScript and PDF graphics in 
http://cran.r-project.org/doc/Rnews/Rnews_2006-2.pdf for an example, 
plus also possibly http://www.stat.auckland.ac.nz/~paul/R/CM/CMR.html.


Paul


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


--
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
p...@stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.