[R] contour plot or persp plot with log scale?

Duncan Murdoch murdoch at stats.uwo.ca
Thu Feb 12 20:14:57 CET 2009

On 2/12/2009 12:04 PM, Gilbert Brenes wrote:
> Hi.
> Is it possible to draw a contour plot (with contour or filled contour) or a 
> a surface plot (with persp or persp3d) with the z axis in a log scale?

For persp or persp3d I think you'd have to do the log transformation 
yourself.  For example,

x <- 1:100
y <- 1:100
z <- outer(x,y, function(x, y) exp(x/10 + y/10)
logz <- log(z, 10)
persp3d(x,y,logz, axes=FALSE, zlab="z", col="red")
axes3d(c("x", "y"))
axis3d("z", at=pretty(logz), labels=10^pretty(logz))

Duncan Murdoch

More information about the R-help mailing list