[R] lattice background grid

David Winsemius dwinsemius at comcast.net
Fri Apr 9 05:32:43 CEST 2010


On Apr 8, 2010, at 11:07 PM, Wen Huang wrote:

> Hi,
>
> I wonder if anyone knows how to control color and darkness of the  
> background grid generated by ' type = c("g", "p") ' in a lattice  
> plot (e.g., in xyplot). The documentation does not seem to offer a  
> way to change them.
>

I wonder.

Here's what I see based on the documentation
?panel.grid
# has col.line as one of 6 arguments ... so ...
# with the example in ?xyplot ...
# -------------
EE <- equal.count(ethanol$E, number=9, overlap=1/4)
## Constructing panel functions on the fly; prepanel
xyplot(NOx ~ C | EE, data = ethanol,
        prepanel = function(x, y) prepanel.loess(x, y, span = 1),
        xlab = "Compression Ratio", ylab = "NOx (micrograms/J)",
        panel = function(x, y) {
            panel.grid(h=-1, v= 2, col.line="red", lty=3)
            panel.xyplot(x, y)
            panel.loess(x,y, span=1)
        },
        aspect = "xy")

Seems to alter "them", at least to the minimal extent of the offered  
explanation.

-- 
David
--

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list