I have an XYZ data group, where X and Y are the coordinates and Z is the height (LiDAR points). I am trying to build this point cloud with a gradient based on the Z value.
Here is what I still have:
myData <- read.csv("./52I212_plot10.las.csv")
myData <- subset(myData, select=c(X,Y,Z))
myData$normalZ <- (myData$Z-min(myData$Z))/(max(myData$Z)-min(myData$Z))
str(myData)
With this I am trying to create a graph using
library(lattice)
ramp <- colorRampPalette(c("lightblue", "red"))
cloud(myData$Z ~ myData$X + myData$Y, xlab="X", ylab="Y", zlab="Z",pch=20,
col.point=ramp(10)[myData$normalZ*10])
I expected Z values to have one of ten possible colors between lightblue and red.

When I change the plot command to
cloud(myData$Z ~ myData$X + myData$Y, xlab="X", ylab="Y", zlab="Z",pch=20,
col.point=gray(myData$normalZ))
I get what is much closer to what I need:

I suspect that I am doing something wrong on the color ramp, but I cannot understand that.
early
Raphael
EDIT
This question: How to combine vector values with colors from the color ramp in R? They helped me a lot, but I still don’t understand what I did wrong. This code works:
myData$normalZ <- (myData$Z-min(myData$Z))/(max(myData$Z)-min(myData$Z))
ramp <- colorRamp(c("lightblue", "red"))
cols <- ramp(myData$normalZ)
cloud(myData$Z ~ myData$X + myData$Y, xlab="X", ylab="Y", zlab="Z",pch=20,
col.point=rgb(cols,maxColorValue = 256))

, , - , .