On Jul 6, 2014, at 4:35 PM, Sunny Srivastava wrote: > Hello R-helpers: > > I think there is some problem with my code, but I would like to seek you > help because I can't spot it. > > I have a data.frame defined as follows: > > testdf <- structure(list(yy = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, > 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("R", "L"), class = c("ordered", > "factor")), > xx = c(8L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 32L, > 33L, 34L, 37L, 38L, 44L, 47L, 48L), > zz = c(-0.0509470162236187, -0.127284016213917, > -0.148955671035087, -0.142907338502986, -0.160948815798959, > -0.173350477727937, -0.161083124553469, > -0.14273409035068, -0.0214438692797626, > -0.0628618704957434, -0.0877747107755074, -0.0948371137126557, > -0.0659475583478307, -0.0601482978919971, > -0.0339547824620206, -0.0433516197870341)), > .Names = c("yy", "xx", "zz"), > row.names = c("25", "26", "27", "28", "29", "210", > "211", "212", "213", "214", "215", "216", "217", "218", "219", "220"), > class = "data.frame") > > I would like to see a 'levelplot' of yy vs xx, but the value of xx creates > problem in the distribution of colors. I am guessing it is due to the > value of xx = 8. The levelplot below seems to be fine.
I think the fundamental problem is that you are trying to use levelplot with a categorical variable on the RHS of the formula. That is NOT what is expected. You are the one who expanded the X range to c(0,50) and the color range to seq(-0.3, 0.3, length = 20). -- David. > > library(latticeExtra) > > > ## ok; note the subset argument! > levelplot(zz ~ xx + yy, testdf, par.settings = custom.theme.2(), subset = > xx != 8, > scales = list(x = list(cex = 0.5, rot=90), y = list(cex = 0.5), > alternating = FALSE), > xlim = c(0, 50), > at = seq(-0.3, 0.3, length = 20), > panel = function(x, y, z, ...) { > panel.levelplot(x, y, z,...) > }, > colorkey=list(labels = list(cex = 1.5)) > ) > > If I remove the subsetting of xx != 8, then the distribution of colors is > wrong. Specifically, it ranges from xx =1 to 20 for y = R, which is > incorrect. What am I missing here? Note that using the default color > scheme has no effect. > > ## seems to be a bug ? see xx = 1 to 20; note that the subset argument is > removed > levelplot(zz ~ xx + yy, testdf, par.settings = custom.theme.2(), > scales = list(x = list(cex = 0.5, rot=90), y = list(cex = 0.5), > alternating = FALSE), > xlim = c(0, 50), > at = seq(-0.3, 0.3, length = 20), > panel = function(x, y, z, ...) { > panel.levelplot(x, y, z,...) > }, > colorkey=list(labels = list(cex = 1.5)) > ) > > > Thanks, > S. > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. David Winsemius Alameda, CA, USA ______________________________________________ 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.