Hi Scott,
The trick is to postpone plotting (plot = FALSE) and then do plotdev() with the
required limits:
library(plot3D)
x <- z <- seq(-4, 4, by=0.2)
y <- seq(-6, 6, by=0.2)
M <- mesh(x,y,z)
R <- with(M, sqrt(x^2 + y^2 +z^2))
p <- sin(2*R)/(R+1e-3)
x.limits <- c(-2, 2)
y.limits <- c(-2, 2)
slice3D(x,y,z, colvar=p, xs=0, ys=c(0, 4), zs=NULL, scale=F,
ticktype="detailed", plot = FALSE)
plotdev(xlim=x.limits, ylim=y.limits)
This should work.
Karline
Message: 25
Date: Wed, 6 Aug 2014 23:21:04 +
From: "Waichler, Scott R"
To: "R. Help"
Cc: "karline.soeta...@nioz.nl"
Subject: [R] Using axis limits with plot3D
Message-ID:
<074c83dad4825242a20b2d83fdbcb888765...@ex10mbox03.pnnl.gov>
Content-Type: text/plain; charset="us-ascii"
I would like to use the functions in the plot3D package but I am having trouble
getting the axis limits to work correctly. The slices plotted by the code
below go beyond the bounds of the persp box and obscure the axis information.
How can I show just the part of the domain within x.limits and y.limits?
library(plot3D)
x <- z <- seq(-4, 4, by=0.2)
y <- seq(-6, 6, by=0.2)
M <- mesh(x,y,z)
R <- with(M, sqrt(x^2 + y^2 +z^2))
p <- sin(2*R)/(R+1e-3)
x.limits <- c(-2, 2)
y.limits <- c(-2, 2)
slice3D(x,y,z, colvar=p, xs=0, ys=c(0, 4), zs=NULL, xlim=x.limits,
ylim=y.limits, scale=F, ticktype="detailed")
Thanks,
Scott Waichler
Pacific Northwest National Laboratory
Richland, WA, USA
__
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.