I am making a lattice levelplot
from x
and y
factors that range from [0,1]:
x y level
This is revision #3
Here we go (again). :)
This is weird, if I set n to anything below 15, things seem to work?
df <- read.table("http://dl.dropbox.com/u/31495717/stackoverflow.overlaps.list.txt",
sep = "\t", header = FALSE)
names(df) <- c("x", "y", "level")
df$level <- round(df$level*100, 0)
n <- 10
col.seq <- seq(10, 80, length.out = n)
brks <- c(0, seq(10, 80, length.out = n), 100)
cuts <- cut(df$level, breaks = brks)
colors <- colorRampPalette(c("red", "white"))(length(levels(cuts))-1)
colors <- c(colors, "black")
cls <- rep(colors, times = table(cuts))
print(levelplot(cuts~x*y,
data = df,
cuts = n,
col.regions=cls,
xlab="",
ylab="",
aspect="iso",
scales=list(
x=list(rot=90)
),
panel=function(...) {
arg <- list(...)
panel.levelplot(...)
panel.text(df$x, df$y, df$level, cex=0.5)
},
colorkey = list(col = colors, at = brks)
))