[Rd] proposal: lattice/levelplot with zlim
Wolfram Fischer - Z/I/M
wolfram@fischer-zim.ch
Thu Jan 23 17:24:19 2003
I suggest to add an argument zlim to levelplot().
This would be a help e.g. to plot a sort of correlogram
(or corrgram, how Micheal Friendly named it, c.f.:
http://euclid.psych.yorku.ca/SCS/Papers/corrgram.pdf)
When using panel.catlevelplot which I suggested yesterday
the graphic becomes even nicer.
Wolfram
#---- ADDITIONAL ARGUMENT FOR levelplot() --------------------------
zlim = range(z[!is.na(z)]),
#---- ADDITIONAL CODE IN levelplot() -------------------------------
#--- ORIGINAL ---
# zrng <- extend.limits(range(z[!is.na(z)]))
#--- NEW ---
zrng <- extend.limits( zlim )
#---- EXAMPLE ------------------------------------------------------
library(EMV)
data(swiss)
example.corplot.swiss <- function( ... ){
x.cor <- cor( knn( as.matrix( swiss ) )$data )
diag( x.cor ) <- 0
x.names <- colnames( swiss )
x.cor.data <- data.frame(
x = rep( x.names, length( x.names ) )
, y = rep( x.names, each=length( x.names ) )
, val = as.vector( x.cor )
)
print( levelplot( val ~ x + y, data = x.cor.data
## --- omit next argument if panel.catlevelplot is not yet defined ---
, panel = panel.catlevelplot
, scales= list(
x = list( labels = x.names, rot=90, alternating=F
, at = 1 : length( x.names ) )
, y = list( labels = x.names, alternating=F
, at = 1 : length( x.names ) )
)
, zlim = c( -1, 1 )
, ...
))
}
#---- --------------------------------------------------------------