[R] pdf() black&white; panel titles in lattice

Deepayan Sarkar deepayan.sarkar at gmail.com
Fri Jul 15 19:16:36 CEST 2005


On 7/15/05, ftorrei2 at uiuc.edu <ftorrei2 at uiuc.edu> wrote:
> Hello,
> 
> I have two questions:
> 
> 1. How can I get black and white graphics using the pdf()
> device? I have tried pdf(Name.pdf, bg="white", fg"black"), but
> I still get  full-color graphics.

See ?trellis.device, specifically the 'color' argument.

> 2. When using lattice, how do I change the title for each
> panel?  By default it uses the categories of the grouping
> factor. I would like to modify the labels in the graphic
> without changing the data. 

See the entry for 'strip' in ?xyplot, as well as ?strip.default. For
one conditioning variable this can be as simple as

xyplot(Sepal.Length ~ Sepal.Width | Species, iris, 
    strip = strip.custom(factor.levels = c("I. setosa", 
                                  "I. versicolor", "I. verginica")))

or 

xyplot(Sepal.Length ~ Sepal.Width | Species, iris, 
    strip = strip.custom(factor.levels = 
        expression(italic("I. setosa"), 
                         italic("I. versicolor"), 
                         italic("I. verginica"))))


> Also, how do I add a title above
> the graphic referring to this factor (not the main title of
> the graph)? The title for the xlab refers to the independent
> factor within each panel. I would like to explain what each
> panel represents with something similar to xlab, this title
> being above the graphic if possible.

You may be satisfied with 

xyplot(Sepal.Length ~ Sepal.Width | Species, iris, 
          strip = strip.custom(strip.names = TRUE))

If not, use the 'key' argument (described in ?xyplot).

Deepayan




More information about the R-help mailing list