Plotting straight surface with lattice::wireframe()

限于喜欢 提交于 2019-12-08 12:15:54

问题


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.


回答1:


Just add a zlim argument.

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




回答2:


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.)



来源:https://stackoverflow.com/questions/17762904/plotting-straight-surface-with-latticewireframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!