11010tianyi / playwith

Automatically exported from code.google.com/p/playwith
0 stars 2 forks source link

playwith does not plot all panels in a lattice xyplot multipanel display - R code and screen shot included #72

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, 
First,  let me say playwith() is excellent and functionally what I was looking 
for in terms of zoom capability for large data visual display.  However,  as I 
tested some cases (corner?) I started encountering some issues.  Details below 
and screen shot attached.

What steps will reproduce the problem?
I am attaching a self-contained R script that generates random data close to 
the use case. The R code generates ~50k x, y data points (physical locations,  
same scale) along with a 6 level and 8 level factor used for conditioning and 
grouping.  The data 

What is the expected output? What do you see instead?
6 panels each full of data with ability to zoom in to see the structure of the 
data at the local nodes.  Plot should look the same as plotted to the default 
graphics device.   Attached a .png screen capture of the two plots side by 
side.  Two of the 6 panels fail to plot at in the playwith plot (panels 3 and 
5).  Zoom works,  but sometimes “hesitates”.

What version of the product are you using? On what operating system?
R:  2.13.1 (tried both 32 bit and 64 bit)
OS:  Windows 7 Ultimate 64 bit
Java:  Java 6 Update 26 (both 32 bit and 64 bit installed)
GTK2-Runtime: 2.22.0.2010-10-21-ash
R packages: 
gWidgetsRGtk2 "0.0-76"
RGtk2: "2.20.17"
Playwith: "0.9-53"
rj: "0.5.5-4"           
rJava: "0.9-2"

Using Eclipse 64 bit IDE with StatET and have set up R 32 bit and 64 bit 
environments (and properly linked them to the correct JRE runtimes).  I have 
tried the example both in Eclipse and just from R (running in SDI mode)

Please provide any additional information below.
# R code (also attached in case formatting breaks it.
library(lattice)
library(playwith)

# list of functions with range [0,1] and “shapes” to plot at nodes of data
lineShp <- function(x) {x}
quadShp <- function(x) {x*x}
sinShp <- function(x) {0.5*sin(x*2*pi)+0.5}
cosShp <- function(x) {0.5*cos(x*2*pi)+0.5}
expShp <- function(x) {exp(x)/2.718282}
randShp <- function(x) {runif(length(x))}
sawShp <- function(x) {(x-floor(x+.5))+0.5}
funList <- c("lineShp", "quadShp", "sinShp", "cosShp", "expShp", "randShp", 
"sawShp")

# make data for one node by sampling one of the functions from the list and 
running it on runif()
makeData <- function(ix, iy, n) {
    x <- runif(n)
    y <- eval(call(sample(funList,1),x))
    cbind(x+ix, y+iy)   
}

# make data for each node by calling the makeData for each of the grid points
makeBigData <- function(gridPts, n){
    tmp <- NULL
    for(i in 1:nrow(gridPts)){
        ix <- gridPts[i,1]
        iy <- gridPts[i,2]
        tmp <- rbind(tmp,makeData(ix, iy, n))
    }
    tmp
}
# make a grid of nodes where the data will be plotted
gridPts <- as.data.frame(expand.grid(iX = seq(1,50,2), iY=seq(1,50,2)))

# construct the data.
test <- as.data.frame(makeBigData(gridPts, 80))

# add grouping and conditioning variables to the data
dataRows <- nrow(test)
cond <- sample(gl(6, dataRows/6), dataRows)
grps <- sample(gl(8, dataRows/8), dataRows)
test <- cbind(cond, grps, test)

# some lattice parameters I would like to have outside the call of xyplot (so 
as not to
# have to call it each time I make a plot like this)
trellis.par.set(superpose.symbol=list(pch=16), 
strip.background=list(col="lightblue"))
lattice.options(default.args = list(as.table=TRUE, between = list(x=.75, 
y=.75)))

# make the lattice plot object.
plt <- xyplot(V2 ~ V1 | cond ,groups = grps, data = test,
        auto.key = list(space = "right", title="Label"),
        aspect = "iso", alpha = 0.6, cex = .4, layout=c(3,2),
        main = "X,Y Locations Conditioned by cond, Grouped by grps",
        as.table = TRUE, subscripts = TRUE,  
        panel = function(x, y, groups, subscripts, ...) {
            grid.rect(.5,.5,1,1, gp = gpar(fill = "lightgreen"))
            panel.xyplot(x, y, groups=groups, subscripts=subscripts,...)
        })

plot(plt)  # plot with the default graphics device
playwith(plt)  # plot using playwith

Original issue reported on code.google.com by Randall....@gmail.com on 26 Sep 2011 at 6:44

Attachments: