Robert,

While you're re-opening the code, I'd like to ask about the col parameter. I
personally had trouble with setting the right range for my palette as zlim
is overwritten. For instance I have a raster which range isn't symmetric
around 0, but I have a palette which I'd like to be symmetric around 0. I
could solve that in plot() by setting zlim=c(-10,10) so color would stretch
from -10 to 10 and be centered on 0, but it's not working in plot3D.

Using a drape with @legend@colortable appeared to me as a solution by
reading the code, but I couldn't find any setter for it (is it new ?).

library(raster)
library(rgl)
r <- raster(matrix(c(-5,rep(0, 14), 10), nrow=4))
cr <- colorRampPalette(c('blue','white','red'))
# I'd like 0's to be white
plot(r, col=cr(21)) # problem
plot(r, zlim=c(-10,10), col=cr(21)) # solution
plot3D(r, zlim=c(-10,10), col=cr)


Etienne

2011/7/14 Robert Hijmans <r.hijmans@gmail.com>

> > (plot3D is in fact in the rasterVis package now)
> >
> > There's an adjustment factor additional to the zfac parameter. It is
> > impossible to override it. The solution I've found is to comment these
> > lines
> > and run the function under another name (these lines are present 2
> times).
> >
> >#         adj <- zlen/min(ylen,xlen)
> >#         X <- X * adj * zfac
> >#         Y <- Y * adj * zfac
> >
> >If you need to keep the zfac, I'd suggest to put it directly on Z.
> >Z <- t((getValues(x, format='matrix'))[nrow(x):1,]) * zfac
> >
> >I'd be curious to hear why is the z scaling factor is applied in that
> >fashion.
>
> The zfac could be changed, but I think the main issue is the "adj" factor
> that scales the x, y and z values to get a nice 3D plot. It may be possible
> to do this differently, and I will try to do that; I had overlooked this
> problem (of wrong coordinates on the axis, and not being able to correctly
> plot vector data on top). Thanks for pointing this out,
>
> Robert
>
>
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/plot3D-raster-coordinates-tp6558234p6585449.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

