Search code examples
rlatticewireframe

Plotting straight surface with lattice::wireframe()


Assume I want to plot the following dataframe:

df <- data.frame(expand.grid(1:10,1:10),rep(10,100))
colnames(df) <- c("x","y","z")

with the lattice wireframe() function:

wireframe(z~x*y,df,colorkey=TRUE,drape=TRUE)

How do I get it to plot the given coordinates? I would assume it has something to do with having to scale/adjust the z-axis as the automatic scaling within wireframe is probably confused by all z-coordinates being equal.

enter image description here


Solution

  • Just add a zlim argument.

    wireframe(z~x*y,df,colorkey=TRUE,drape=TRUE, zlim=c(0,20))
    

    Constant function