[R] xyplot of function only shows diagonal plots

DrHatch DrHatch at PatAndHatch.org
Wed Jul 7 21:17:47 CEST 2010


I expected this script to show nine panels, each with a plot of the 
function.
But when I run it, only the diagonal panels have content.
Executing > print(trel_1) shows what I expected in the upper left corner.
I am using R ver. 2.11.0 and lattice ver. 0.18-8 on Windows XP under 
Eclipse and StatET.
I have searched the documentation, but found no answer. What am I missing?

--- simple.R ---

# Test xyplot layout for a function
#
require("lattice")

    f <- function(x,a,b){return( a * sin(x)+ b)}
    trellis.par.set(theme = canonical.theme("Windows"))
    x <- seq(-4,4, by=0.1)
# case 1x1
    a <- c( 1 )
    b <- c( 3 )
    trel_1 <- xyplot(f(x,a,b) ~ x | a * b, ,  type = "l",  
            main = "1x1", ylab = "f(x)", xlab = "x",
            xlim = c(-6,6), ylim = c(-6,6),   )
# case 3x3
    a <- c(1,2,3)
    b <- c(1,2,3)
    trel_3 <- xyplot(f(x,a,b) ~ x | a * b, ,  type = "l",  
                    main = "3x3", ylab = "f(x)", xlab = "x",
                    xlim = c(-6,6), ylim = c(-6,6),   )

print(trel_3)
#print(trel_1)

--- end of simple.R ---



More information about the R-help mailing list