R-sters: I'm interested in keeping data plotted in persp to preserve the wireframe look, I'd just like to change one of the lines drawn (in either the x or y direction) into a different color so that it stands out. Or is there some way to add a line (say, via lines(), or abline()) to a persp() plot at the designated x or y that would follow the z surface contour? I could add a line using 2D representations of the data, but I'd like to use the perspective plot if possible. Any advice? Cheers, Jeff
Jeff -
See the section titled "Value:" and example (2) from
help("persp")
for instructions and an example of doing exactly what you ask.
- tom blackwell - u michigan medical school - ann arbor -
On Tue, 17 Feb 2004, Jeff Jorgensen wrote:
> R-sters:
>
> I'm interested in keeping data plotted in persp to preserve the
wireframe
> look, I'd just like to change one of the lines drawn (in either the x
or y
> direction) into a different color so that it stands out.
>
> Or is there some way to add a line (say, via lines(), or abline()) to a
> persp() plot at the designated x or y that would follow the z surface
> contour? I could add a line using 2D representations of the data, but
I'd
> like to use the perspective plot if possible.
>
> Any advice?
>
> Cheers,
>
> Jeff
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
The help file for persp (in R 1.8.1, at least) includes a function
to "Add to existing persp plot". Have you tried that? Alternative,
have you considered "wireframe" in package lattice?
hope this helps. spencer graves
Jeff Jorgensen wrote:
> R-sters:
>
> I'm interested in keeping data plotted in persp to preserve the
> wireframe look, I'd just like to change one of the lines drawn (in
> either the x or y direction) into a different color so that it stands
> out.
>
> Or is there some way to add a line (say, via lines(), or abline()) to
> a persp() plot at the designated x or y that would follow the z
> surface contour? I could add a line using 2D representations of the
> data, but I'd like to use the perspective plot if possible.
>
> Any advice?
>
> Cheers,
>
> Jeff
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
Tom,
Thanks for the nudge to reexamine the instructions. I wasn't calling the
right object with "pmat". I first had to create a perspective plot
object
which creates the plot, and then call *that* object for "pmat", not
the
matrix I used to create the plot in the first place:
surface<-persp(x=..., y=..., z=perspmatrix, ....)
## function needed to add things to persp, found in the ?persp help menu ##
trans3d <- function(x,y,z, pmat) {
tr <- cbind(x,y,z,1) %*% pmat
list(x = tr[,1]/tr[,4], y= tr[,2]/tr[,4])
}
lines(trans3d(x=..., y=..., z=..., pmat=surface), ...)
At 07:45 PM 2/17/2004 -0500, you wrote:>Jeff -
>
>See the section titled "Value:" and example (2) from
help("persp")
>for instructions and an example of doing exactly what you ask.
>
>- tom blackwell - u michigan medical school - ann arbor -
>
>On Tue, 17 Feb 2004, Jeff Jorgensen wrote:
>
> > R-sters:
> >
> > I'm interested in keeping data plotted in persp to preserve the
wireframe
> > look, I'd just like to change one of the lines drawn (in either
the x or y
> > direction) into a different color so that it stands out.
> >
> > Or is there some way to add a line (say, via lines(), or abline()) to
a
> > persp() plot at the designated x or y that would follow the z surface
> > contour? I could add a line using 2D representations of the data, but
I'd
> > like to use the perspective plot if possible.
> >
> > Any advice?
> >
> > Cheers,
> >
> > Jeff
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> >