[R] 3-D response surface using wireframe()

array chip arrayprofile at yahoo.com
Fri Apr 9 22:46:51 CEST 2010


David, 

Thanks for the 2 previous posts from Sarkar. Actually, I am now one step closer. I am now able to remove the 3 outer lines of the bounding box using par.box argument, even Sarkar said in his 2008 post that par.box() does not control different boundaries, so maybe it was fixed. 

Replacing "par.box=list(lwd=2)" in my original code with "par.box=list(lwd=2,col=c(1,1,1,NA,1,1,NA,NA,1))" will now remove the 3 outer lines of the bounding box. The only thing missing here is the 3 inner lines of the box (behind the plot) are dashed lines, not solid. And par.box argument only control those 9 visible lines of the bounding box.

As for how to draw grid lines onto the 3 surfaces, I still have no clue. But as you pointed out Sarkar indicated in his 2007 post that it might be possible. 

Thanks

John

--- On Fri, 4/9/10, David Winsemius <dwinsemius at comcast.net> wrote:

> From: David Winsemius <dwinsemius at comcast.net>
> Subject: Re: [R] 3-D response surface using wireframe()
> To: "array chip" <arrayprofile at yahoo.com>
> Cc: r-help at r-project.org
> Date: Friday, April 9, 2010, 3:48 PM
> I do not think the mail server
> accepts .jpg formats which was the  
> format in which I got your attachment the first time
> (because of your  
> having copied me directly.)  I don't see much need to
> send a pdf  
> because the code you offered does work and the data made it
> through  
> (because .txt and .pdf are types that the mailserver
> accepts.)
> 
> Back in 2007 Sarkar suggested that it would be possible to
> project  
> grids on the walls of the bounding box but since the
> original poster  
> did not reply, it appears Sarkar did not deliver a worked
> solution.
> 
> http://finzi.psych.upenn.edu/R/Rhelp02/archive/95759.html
> 
> And then in 2008 he referred the questioner to the section
> of the   
> Lattice examples I earlier cited:
> 
> http://finzi.psych.upenn.edu/Rhelp10/2008-October/176466.html
> 
> -- 
> David.
> 
> On Apr 9, 2010, at 3:27 PM, array chip wrote:
> 
> > Sorry the example plot didn't go through last time,
> here it is:
> >
> > Thanks
> >
> > John
> >
> > --- On Fri, 4/9/10, array chip <arrayprofile at yahoo.com>
> wrote:
> >
> >> From: array chip <arrayprofile at yahoo.com>
> >> Subject: Re: [R] 3-D response surface using
> wireframe()
> >> To: "David Winsemius" <dwinsemius at comcast.net>,
> "Felix Andrews" <felix at nfrac.org 
> >> >
> >> Cc: r-help at r-project.org
> >> Date: Friday, April 9, 2010, 1:09 PM
> >> Hi David and Felix,
> >>
> >> Thank you very much for your suggestions. To be
> honest,
> >> this has become beyond my understanding of lattice
> plots
> >> now. I am relatively new to lattice plots, so have
> no idea
> >> how function within function works (for example,
> how does
> >> panel.3dpolygon() within panel.3d.wireframe()
> within
> >> wirefarme() works, totally have no clue.
> >>
> >> Felix, your example code of panel.3dpolygon() for
> volcano
> >> plot does what I want, but again, I don't know how
> to tweak
> >> your example to suit my case.
> >>
> >> I attached an example dataset, and an example of
> the plot
> >> that I wanted to make (especially those grid lines
> on the 3
> >> bounding surfaces of the box, and if possible
> remove those
> >> front edges of the box to make it look like
> open).
> >>
> >>
> dat<-read.table("dat.txt",sep='\t',header=T,row.names=1)
> >>
> >> library(lattice)
> >> wireframe(z ~ x*y, data = dat,
> >> scales = list(arrows = FALSE, cex=0.9,
> col="black",font=3,
> >> tick.number=6, z=list(tick.number=10,
> >> tck 
> >> = 
> >> 0.8 
> >> ,distance 
> >>
> =0.8),x=list(tck=0.8,distance=0.6),y=list(tck=0.7,distance=0.6)),
> >> zlim=seq(-14,4,by=2),
> >> zlab=list(label="Z", rot=90,cex=0.9),
> >> xlab=list(label="X", rot=15.5),
> >> ylab=list(label="Y", rot=-33),
> >> drape = T,
> >> at=seq(min(dat$z),max(dat$z),length=50),
> >> col.regions=rgb(colorRamp(c("white",
> "red"))(seq(0, 1,
> >> length = 50)), max = 255),
> >> colorkey = F,
> >> par.box=list(lwd=2), ## line width of box
> >> screen = list(z = 210, x = -75, y = 5),
> >> scpos=list(x=9,y=5,z=2) ## where axes are draw
> >> )
> >>
> >> Thank you all very much for the help. It's fun to
> learn.
> >>
> >> John
> >>
> >> --- On Thu, 4/8/10, Felix Andrews <felix at nfrac.org>
> >> wrote:
> >>
> >>> From: Felix Andrews <felix at nfrac.org>
> >>> Subject: Re: [R] 3-D response surface using
> >> wireframe()
> >>> To: "David Winsemius" <dwinsemius at comcast.net>
> >>> Cc: "array chip" <arrayprofile at yahoo.com>,
> >> r-help at r-project.org
> >>> Date: Thursday, April 8, 2010, 9:56 PM
> >>> On 9 April 2010 11:18, David
> >>> Winsemius <dwinsemius at comcast.net>
> >>> wrote:
> >>>> On Apr 8, 2010, at 8:29 PM, array chip
> wrote:
> >>>>
> >>>>> David,
> >>>>>
> >>>>> Thansk again! Sarkar's Lattice book
> is
> >> excellent
> >>> source for lattice. Here
> >>>>> is a link for all the figures and
> codes used
> >> in
> >>> the book. You example is
> >>>>> figure 13.7.
> >>>>>
> >>>>> http://lmdvr.r-forge.r-project.org/figures/figures.html
> >>>>>
> >>>>> I got the first point! For the second
> point
> >> below,
> >>> Figure 13.7 an
> >>>>> excellent example for projecting the
> 3D
> >> dataset
> >>> onto the bounding surface,
> >>>>> but it's not what I meant. I think I
> didn't
> >>> explain what I wanted clearly.
> >>>>> What I really wanted is a simple
> straight
> >> grid
> >>> lines across the tick marks
> >>>>> for 3 bounding surfaces of the box,
> not a
> >>> projection of the 3D dataset. Hope
> >>>>> I have explained clearly this time.
> >>>>
> >>>> You have not convinced me that I
> misunderstood
> >> what
> >>> you wanted. I figured
> >>>> that you would use something other than
> >> transforming
> >>> the data driven contour
> >>>> lines. But if you want to use a lattice
> function
> >> there
> >>> is a panel.grid, but
> >>>> I still suspect it will need to be 3dto3d
> >> transformed
> >>> onto one of the "lim"
> >>>> extremes.
> >>>
> >>> Might be a little easier to use
> panel.3dpolygon from
> >>> latticeExtra.
> >>> (or not)
> >>> e.g. something like
> >>>
> >>> wireframe(volcano, drape = TRUE, scales =
> list(arrows
> >> =
> >>> FALSE),
> >>>   panel.3d.wireframe =
> function(x,y,z,...) {
> >>> 
>    panel.3dwire(x,y,z,...)
> >>>     panel.3dpolygon(x =
> rep(pretty(x), each = 3),
> >>> y = min(y), z =
> >>> c(range(z),NA),
> >>>
> >>>     ..., border="grey",
> lwd=2)
> >>>   })
> >>>
> >>>
> >>>>
> >>>>>
> >>>>> Many thanks
> >>>>>
> >>>>> John
> >>>>>
> >>>>>
> >>>>> --- On Thu, 4/8/10, David Winsemius
> <dwinsemius at comcast.net>
> >>> wrote:
> >>>>>
> >>>>>> From: David Winsemius <dwinsemius at comcast.net>
> >>>>>> Subject: Re: [R] 3-D response
> surface
> >> using
> >>> wireframe()
> >>>>>> To: "array chip" <arrayprofile at yahoo.com>
> >>>>>> Cc: r-help at r-project.org
> >>>>>> Date: Thursday, April 8, 2010,
> 3:46 PM
> >>>>>>
> >>>>>> On Apr 8, 2010, at 3:13 PM, array
> chip
> >> wrote:
> >>>>>>
> >>>>>>> David,
> >>>>>>>
> >>>>>>> That does the job! Thanks a
> lot.
> >>>>>>>
> >>>>>>> Now I am very very close to
> what I
> >> want.
> >>> Still have a
> >>>>>>
> >>>>>> couple of
> >>>>>>>
> >>>>>>> small adjustments to make.
> >>>>>>>
> >>>>>>> 1. I use drape=TRUE to draw
> grid and
> >> color
> >>> on the
> >>>>>>
> >>>>>> surface, is there
> >>>>>>>
> >>>>>>> a parameter to adjust the
> density of
> >> the
> >>> grid?
> >>>>>>
> >>>>>> If you mean the spacing between
> points,
> >> then
> >>> isn't that
> >>>>>> determined by
> >>>>>> the density of the gridded data
> >> arguments
> >>> before they get
> >>>>>> to the
> >>>>>> wireframe function?
> >>>>>>
> >>>>>>>
> >>>>>>> 2. Is there a way that I can
> add grid
> >> to
> >>> the axis
> >>>>>>
> >>>>>> surface? I mean
> >>>>>>>
> >>>>>>> the sides of the box, between
> x &
> >> y,
> >>> between x
> >>>>>>
> >>>>>> & z, and between y &
> >>>>>>>
> >>>>>>> z? And I need to choose which
> 3 side
> >> of
> >>> the box that I
> >>>>>>
> >>>>>> want to add
> >>>>>>>
> >>>>>>> grid?
> >>>>>>
> >>>>>> See Figure 13.7 of Sarkar's
> Lattice text
> >> for
> >>> an example of
> >>>>>> a panel
> >>>>>> function that collapses the
> contourLines
> >> of
> >>> the volcano
> >>>>>> dataset at the
> >>>>>> top bounding surface by using
> >> ltransform3dto3d
> >>> with a z
> >>>>>> argument of
> >>>>>> zlim.scaled[2]. I would think that
> a
> >> grid
> >>> could be 3dto3d
> >>>>>> transformed
> >>>>>> similarly.
> >>>>>>
> >>>>>> --
> >>>>>> David.
> >>>>>>
> >>>>>>>
> >>>>>>> Thank you all for the help.
> It's fun
> >> to
> >>> play with
> >>>>>>
> >>>>>> wireframe
> >>>>>>>
> >>>>>>> John
> >>>>>>>
> >>>>>>> --- On Wed, 4/7/10, David
> Winsemius
> >> <dwinsemius at comcast.net>
> >>>>>>
> >>>>>> wrote:
> >>>>>>>
> >>>>>>>> From: David Winsemius
> <dwinsemius at comcast.net>
> >>>>>>>> Subject: Re: [R] 3-D
> response
> >> surface
> >>> using
> >>>>>>
> >>>>>> wireframe()
> >>>>>>>>
> >>>>>>>> To: "array chip" <arrayprofile at yahoo.com>
> >>>>>>>> Cc: r-help at r-project.org
> >>>>>>>> Date: Wednesday, April 7,
> 2010,

> >> 9:22
> >>> PM
> >>>>>>>>
> >>>>>>>> On Apr 7, 2010, at 8:58
> PM, array
> >> chip
> >>> wrote:
> >>>>>>>>
> >>>>>>>>> With the help
> document, i
> >> finally
> >>> find a set
> >>>>>>
> >>>>>> of values
> >>>>>>>>
> >>>>>>>> of for x=,y=
> >>>>>>>>>
> >>>>>>>>> and z= in "screen"
> argument
> >> that
> >>> gives me the
> >>>>>>
> >>>>>> correct
> >>>>>>>>
> >>>>>>>> rotation of
> >>>>>>>>>
> >>>>>>>>> the plot. But now it
> plots x
> >> and y
> >>> axis (tick
> >>>>>>
> >>>>>> marks
> >>>>>>>>
> >>>>>>>> and labels)
> >>>>>>>>>
> >>>>>>>>> along the top of the
> plot.
> >> Is
> >>> there one way to
> >>>>>>
> >>>>>> plot x
> >>>>>>>>
> >>>>>>>> and y axis on
> >>>>>>>>>
> >>>>>>>>> the bottom of the
> plot?
> >>>>>>>>
> >>>>>>>> Look at the scpos argument
> to
> >> specify
> >>> the scales
> >>>>>>
> >>>>>> location.
> >>>>>>>>
> >>>>>>>> (Still
> >>>>>>>> lacking an example and
> >> therrefore
> >>> doing this from
> >>>>>>
> >>>>>> memory.)
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> David
> >>>>>>>>>
> >>>>>>>>> Thanks
> >>>>>>>>>
> >>>>>>>>> John
> >>>>>>>>>
> >>>>>>>>> --- On Wed, 4/7/10,
> David
> >>> Winsemius <dwinsemius at comcast.net>
> >>>>>>>>
> >>>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>>> From: David
> Winsemius
> >> <dwinsemius at comcast.net>
> >>>>>>>>>> Subject: Re: [R]
> 3-D
> >> response
> >>> surface
> >>>>>>
> >>>>>> using
> >>>>>>>>
> >>>>>>>> wireframe()
> >>>>>>>>>>
> >>>>>>>>>> To: "array chip"
> <arrayprofile at yahoo.com>
> >>>>>>>>>> Cc: r-help at r-project.org
> >>>>>>>>>> Date: Wednesday,
> April
> >> 7,
> >>> 2010, 8:07 AM
> >>>>>>>>>> A search with the
> >> following
> >>>>>>>>>> strategy:
> >>>>>>>>>>
> >>>>>>>>>>
> RSiteSearch("lattice
> >> wireframe
> >>> rotate
> >>>>>>
> >>>>>> axes")
> >>>>>>>>>>
> >>>>>>>>>> Followed by
> adding
> >> requests to
> >>> search
> >>>>>>
> >>>>>> earlier
> >>>>>>>>
> >>>>>>>> years'
> >>>>>>>>>>
> >>>>>>>>>> archives produced
> this
> >> link
> >>> which has a
> >>>>>>
> >>>>>> further
> >>>>>>>>
> >>>>>>>> link to a
> >>>>>>>>>>
> >>>>>>>>>> document that
> answers
> >> most of
> >>> your
> >>>>>>
> >>>>>> questions, at
> >>>>>>>>
> >>>>>>>> least the
> >>>>>>>>>>
> >>>>>>>>>> ones that are
> >> comprehensible:
> >>>>>>>>>>
> >>>>>>>>>> http://tolstoy.newcastle.edu.au/R/e2/help/07/03/12534.html
> >>>>>>>>>>
> >>>>>>>>>> --David.
> >>>>>>>>>>
> >>>>>>>>>> On Apr 6, 2010, at
> 7:12
> >> PM,
> >>> array chip
> >>>>>>
> >>>>>> wrote:
> >>>>>>>>>>
> >>>>>>>>>>> I am working
> on
> >> plotting a
> >>> response
> >>>>>>
> >>>>>> surface
> >>>>>>>>
> >>>>>>>> using
> >>>>>>>>>>
> >>>>>>>>>> wireframe(). The
> default
> >>> style/orientation
> >>>>>>
> >>>>>> is
> >>>>>>>>>>>
> >>>>>>>>>>>   
>       z
> >>>>>>>>>>>   
>       |
> >>>>>>>>>>>   
>       |
> >>>>>>>>>>> y   
>    |
> >>>>>>>>>>> \   
>    |
> >>>>>>>>>>> \   
>   |
> >>>>>>>>>>>   
> \
> >>>>>>
> >>>>>>   |
> >>>>>>>>>>>
> >>>>>>>>>>> 
>    \
> >>>>>>
> >>>>>> |
> >>>>>>>>>>>
> >>>>>> \   |
> >>>>>>>>>>>
> >>>>>>>>>>>   
>    \
> >>>>>>
> >>>>>> |
> >>>>>>>>>>>
> >>>>>>>>>>>   
>     \ |
> >>>>>>>>>>>
> >>>>>>>> \|________________x
> >>>>>>>>>>>
> >>>>>>>>>>>   
>       0
> >>>>>>>>>>>
> >>>>>>>>>>> Now what I
> want the
> >>> orientation of
> >>>>>>
> >>>>>> axes is:
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>    z
> >>>>>>>>>>>
> >>>>>>>>>>    |
> >>>>>>>>>>>
> >>>>>>>>>>    |
> >>>>>>>>>>>
> >>>>>>>>>>    |
> >>>>>>>>>>>
> >>>>>>>>>>    |
> >>>>>>>>>>>
> >>>>>>>>>>    |
> >>>>>>>>>>>
> >>>>>>>>>> 
>    /0\
> >>>>>>>>>>>
> >>>>>>>>>>
> /   \
> >>>>>>>>>>>
> >>>>>>>>>> 
>    /
> >>>>>>
> >>>>>>   \
> >>>>>>>>>>>
> >>>>>>>>>> /   
>    \
> >>>>>>>>>>>
> >>>>>>>>>> 
>    /
> >>>>>>>>
> >>>>>>>>    \
> >>>>>>>>>>>
> >>>>>>>>    /
> >>>>>>>>>>
> >>>>>>   \
> >>>>>>>>>>>
> >>>>>>   y
> >>>>>>>>>>
> >>>>>>   z
> >>>>>>>>>>
> >>>>>>>>>> Two z axes? How
> >> interesting!
> >>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> My
> understanding is
> >> that
> >>> the
> >>>>>>>>
> >>>>>>>> screen=list(z=,y=,x=)
> >>>>>>>>>>
> >>>>>>>>>> control the
> orientation
> >> of
> >>> axes, but even
> >>>>>>
> >>>>>> after
> >>>>>>>>
> >>>>>>>> reading the
> >>>>>>>>>>
> >>>>>>>>>> help page of
> screen
> >> argument,
> >>> I still
> >>>>>>
> >>>>>> don't
> >>>>>>>>
> >>>>>>>> understand how
> >>>>>>>>>>
> >>>>>>>>>> to use it.
> >>>>>>>>>>>
> >>>>>>>>>>> screen: "A
> list
> >>> determining the
> >>>>>>
> >>>>>> sequence of
> >>>>>>>>
> >>>>>>>> rotations
> >>>>>>>>>>
> >>>>>>>>>> to be applied to
> the
> >> data
> >>> before being
> >>>>>>
> >>>>>> plotted.
> >>>>>>>>
> >>>>>>>> The initial
> >>>>>>>>>>
> >>>>>>>>>> position starts
> with the
> >>> viewing point
> >>>>>>
> >>>>>> along the
> >>>>>>>>
> >>>>>>>> positive
> >>>>>>>>>>
> >>>>>>>>>> z-axis, and the x
> and y
> >> axes
> >>> in the usual
> >>>>>>>>
> >>>>>>>> position. Each
> >>>>>>>>>>
> >>>>>>>>>> component of the
> list
> >> should
> >>> be named one
> >>>>>>
> >>>>>> of "x",
> >>>>>>>>
> >>>>>>>> "y" or "z"
> >>>>>>>>>>
> >>>>>>>>>> (repititions are
> >> allowed),
> >>> with their
> >>>>>>
> >>>>>> values
> >>>>>>>>
> >>>>>>>> indicating the
> >>>>>>>>>>
> >>>>>>>>>> amount of rotation
> about
> >> that
> >>> axis in
> >>>>>>
> >>>>>> degrees."
> >>>>>>>>>>>
> >>>>>>>>>>> Can anyone
> explain to
> >> me
> >>> how the
> >>>>>>
> >>>>>> screen
> >>>>>>>>
> >>>>>>>> argument
> >>>>>>>>>>
> >>>>>>>>>> works? And what
> values
> >> (x,y,z)
> >>> I should
> >>>>>>
> >>>>>> choose for
> >>>>>>>>
> >>>>>>>> the
> >>>>>>>>>>
> >>>>>>>>>> orientation that I
> want?
> >>>>>>>>>>>
> >>>>>>>>>>> Another
> question is
> >>> wireframe(0 will
> >>>>>>
> >>>>>> draw all
> >>>>>>>>
> >>>>>>>> 8 edges
> >>>>>>>>>>
> >>>>>>>>>> of the cubic by
> default,
> >> is
> >>> there anyway
> >>>>>>
> >>>>>> that I
> >>>>>>>>
> >>>>>>>> can control
> >>>>>>>>>>
> >>>>>>>>>> what edges I can
> draw,
> >> what I
> >>> can hide?
> >>>>>>>>>>>
> >>>>>>>>>>> thanks very
> much!
> >>>>>>>>>>>
> >>>>>>>>>>> John
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>
> >>>
> ______________________________________________
> >>>>>>>>>>>
> >>>>>>>>>>> R-help at 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
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>> David Winsemius, MD
> >>>>>> West Hartford, CT
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>> David Winsemius, MD
> >>>> West Hartford, CT
> >>>>
> >>>>
> ______________________________________________
> >>>> R-help at 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.
> >>>>
> >>>
> >>>
> >>>
> >>> -- 
> >>> Felix Andrews / 安福立
> >>> Postdoctoral Fellow
> >>> Integrated Catchment Assessment and Management
> (iCAM)
> >>> Centre
> >>> Fenner School of Environment and Society [Bldg
> 48a]
> >>> The Australian National University
> >>> Canberra ACT 0200 Australia
> >>> M: +61 410 400 963
> >>> T: + 61 2 6125 4670
> >>> E: felix.andrews at anu.edu.au
> >>> CRICOS Provider No. 00120C
> >>> -- 
> >>> http://www.neurofractal.org/felix/
> >>>
> >>
> >>
> >>
> >> -----Inline Attachment Follows-----
> >>
> >> ______________________________________________
> >> R-help at 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.
> >>
> >
> >
> > ______________________________________________
> > R-help at 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
> 
> 






More information about the R-help mailing list