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

Julian
  • 1,573
  • 2
  • 22
  • 36
  • 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 '13 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 '13 at 15:43

2 Answers2

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

IRTFM
  • 258,963
  • 21
  • 364
  • 487
2

Just add a zlim argument.

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

Constant function

Vincent Zoonekynd
  • 31,893
  • 5
  • 69
  • 78