On Oct 24, 2011, at 4:12 PM, Megan Bartlett wrote:
Hi David,
Thanks for the suggestion - I changed pts1 to pts, but I still got
the same error as before. Do you know what else I'm doing wrong?
I do not. The code that works for me is:
wireframe(z ~ y*x, gridd, drape = TRUE, colorkey= TRUE,
scales = list(arrows = FALSE),
pts = pts1,
panel.3d.wireframe =
function(x, y, z,xlim, ylim, zlim, xlim.scaled, ylim.scaled,
zlim.scaled, pts1, ...)
{
panel.3dwire(x = x, y = y, z = z,
xlim = c(-4, 0),
ylim = c(0, 40),
zlim = c(-160, 0),
xlim.scaled = c(-0.5, 0.5),
ylim.scaled = c(-0.5, 0.5),
zlim.scaled = c(-0.5, 0.5),
...)
xx <- xlim.scaled[1] + diff(xlim.scaled) * (pts$x - xlim[1]) /
diff(xlim)
yy <- ylim.scaled[1] + diff(ylim.scaled) * (pts$y - ylim[1]) /
diff(ylim)
zz <- zlim.scaled[1] + diff(zlim.scaled) * (pts$z - zlim[1]) /
diff(zlim)
panel.3dscatter(x = xx,
y = yy,
z = zz,
xlim = xlim,
ylim = ylim,
zlim = zlim,
xlim.scaled = xlim.scaled,
ylim.scaled = ylim.scaled,
zlim.scaled = zlim.scaled,
...)
})
--
David.
Thanks,
Megan
PS. New code is:
wireframe(z ~ y*x, gridd, drape = TRUE, colorkey= TRUE,
scales = list(arrows = FALSE),
pts = pts1,
panel.3d.wireframe =
function(x, y, z,xlim, ylim, zlim, xlim.scaled,
ylim.scaled, zlim.scaled, pts, ...)
{
panel.3dwire(x = x, y = y, z = z,
xlim = c(-4, 0),
ylim = c(0, 40),
zlim = c(-160, 0),
xlim.scaled = c(-0.5, 0.5),
ylim.scaled = c(-0.5, 0.5),
zlim.scaled = c(-0.5, 0.5),
...)
xx <- xlim.scaled[1] + diff(xlim.scaled) * (pts$x -
xlim[1]) / diff(xlim)
yy <- ylim.scaled[1] + diff(ylim.scaled) * (pts$y -
ylim[1]) / diff(ylim)
zz <- zlim.scaled[1] + diff(zlim.scaled) * (pts$z -
zlim[1]) / diff(zlim)
panel.3dscatter(x = xx,
y = yy,
z = zz,
xlim = xlim,
ylim = ylim,
zlim = zlim,
xlim.scaled = xlim.scaled,
ylim.scaled = ylim.scaled,
zlim.scaled = zlim.scaled,
...)
})
On Mon, Oct 24, 2011 at 12:04 PM, David Winsemius <dwinsem...@comcast.net
wrote:
On Oct 24, 2011, at 1:23 PM, Megan Bartlett wrote:
Hi,
I'm trying to follow the suggestions given by Deepayan Sarkar in
this
message:
http://tolstoy.newcastle.edu.au/R/help/05/11/16135.html
to plot 3-D points on a wireframe plot. The problem is that I keep
getting a
partly formed plot- with the colored lattice visible but no axis
labels or
additional points- with the error message "error using packet 1, 'x'
and
'units' must have length >0". Does anyone know what I'm doing
wrong? The
code I've been using is:
# generate some fake data
data.frame(x = seq(-4, 0, 0.5), y = seq(0, 40, 5))-> df
expand.grid(x = df$x, y = df$y) -> gridd
(gridd$y* gridd$x) -> gridd$z
data.frame(x = runif(10, -4, 0), y = runif(10, 0, 40))-> pts1
pts1$z <- pts1$x*pts1$y
# plot
wireframe(z ~ y*x, gridd, drape = TRUE, colorkey= TRUE,
scales = list(arrows = FALSE),
pts = pts1,
panel.3d.wireframe =
function(x, y, z,xlim, ylim, zlim, xlim.scaled, ylim.scaled,
zlim.scaled, pts1, ...)
{
panel.3dwire(x = x, y = y, z = z,
xlim = c(-4, 0),
ylim = c(0, 40),
zlim = c(-160, 0),
xlim.scaled = c(-0.5, 0.5),
ylim.scaled = c(-0.5, 0.5),
zlim.scaled = c(-0.5, 0.5),
...)
xx <- xlim.scaled[1] + diff(xlim.scaled) * (pts1$x -
xlim[1]) /
diff(xlim)
yy <- ylim.scaled[1] + diff(ylim.scaled) * (pts1$y -
ylim[1]) /
diff(ylim)
zz <- zlim.scaled[1] + diff(zlim.scaled) * (pts1$z -
zlim[1]) /
diff(zlim)
panel.3dscatter(x = xx,
You assigned 'pts1' to 'pts', so you should have used 'pts' above:
y = yy,
z = zz,
xlim = xlim,
ylim = ylim,
zlim = zlim,
xlim.scaled = xlim.scaled,
ylim.scaled = ylim.scaled,
zlim.scaled = zlim.scaled,
...)
})
Thanks so much!
-Megan Bartlett
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
David Winsemius, MD
West Hartford, CT
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.