[R] lattice levelplot axis + custom annotations

David Winsemius dwinsemius at comcast.net
Sun May 3 02:08:47 CEST 2009


On May 2, 2009, at 7:00 PM, Alex Reynolds wrote:

> How would I set the "scales" property of a lattice levelplot, so  
> that I can add specific annotations at specific positions?
>
> For example, I have a 200 x 1000 element levelplot. Along the y-axis  
> (along the 1000-element axis) I would like to add annotations on the  
> left side of the levelplot at elements 120, 300, 500, and 805, which  
> represent clusters of interest.
>
> Currently I have no annotations in my "scales" property:
>
> colorFun <- colorRampPalette(c("white","black"))
> myLevelplot <- levelplot(
> 	t(scale(set.allElements))[,myLevelplot.dendrogram.order],
> 	scales=list(y=list(draw=F),x=list(draw=F)),
> 	colorkey=F, col.regions=colorFun, aspect="iso",
> 	xlab="", ylab="", main="test title",
> 	legend=(list(right=
> 		list(fun=dendrogramGrob,
> 			args=list(x=myLevelplot.dendrogram, ord=  
> myLevelplot.dendrogram.order,
> 				side="right", size=15, size.add=0.0,
> 				add=list(rect=list(col="transparent", fill=NA))))))
> 	)
>
> Is there a straightforward way to add them?

Not sure since you have not provided a reproducible example and not  
really defined what "annotations" means. See if you can derive a more  
genral priciple by comparing with this example  to the first example  
on hte levelplot help page:
x <- seq(pi/4, 5 * pi, length.out = 100)
y <- seq(pi/4, 5 * pi, length.out = 100)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2) * exp(-r/(pi^3))
levelplot(z~x*y, grid, cuts = 50, scales=list(log="e",  
x=list(at=c(1,3.10)), y=list(at=c(1,10))), xlab="",  ylab="",  
main="Weird Function", sub="with log scales", colorkey = FALSE, region  
= TRUE)


>
> Thanks,
> Alex
>
> ______________________________________________
> R-help at 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, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list