0

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

2
  • Sorry but I don't understand your question. What do you mean by "How do I get it to plot the given coordinates"?
    – agstudy
    Jul 20, 2013 at 14:37
  • What I mean is that I would like to see the data that I fed into wireframe (Note that the plot from my example appears to be empty)
    – Julian
    Jul 20, 2013 at 15:43

2 Answers 2

3

This is from the help page scales section: "The most common use for this argument is to set arrows=FALSE, which causes tick marks and labels to be used instead of arrows being drawn (the default)." So just add that as a list value to 'scales':

wireframe(z~x*y,df,colorkey=TRUE,drape=TRUE,
          scales=list(arrows=FALSE), zlim=c(0,10.1))

The failure of wireframe to display anything when the plotted plane is at one of the extremes seems to be at least "unexpected behavior" if not a bug. I suspect you would not see this in real data. Your use of drape doesn't make much sense since the entire data-plane plane gets displayed at the white midpoint. (Again this is probably not a problem if you have something other than this pathological example.)

enter image description here

2

Just add a zlim argument.

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

Constant function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.