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 <fe...@nfrac.org> wrote: > From: Felix Andrews <fe...@nfrac.org> > Subject: Re: [R] 3-D response surface using wireframe() > To: "David Winsemius" <dwinsem...@comcast.net> > Cc: "array chip" <arrayprof...@yahoo.com>, r-help@r-project.org > Date: Thursday, April 8, 2010, 9:56 PM > On 9 April 2010 11:18, David > Winsemius <dwinsem...@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 <dwinsem...@comcast.net> > wrote: > >> > >>> From: David Winsemius <dwinsem...@comcast.net> > >>> Subject: Re: [R] 3-D response surface using > wireframe() > >>> To: "array chip" <arrayprof...@yahoo.com> > >>> Cc: r-help@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 <dwinsem...@comcast.net> > >>> > >>> wrote: > >>>> > >>>>> From: David Winsemius <dwinsem...@comcast.net> > >>>>> Subject: Re: [R] 3-D response surface > using > >>> > >>> wireframe() > >>>>> > >>>>> To: "array chip" <arrayprof...@yahoo.com> > >>>>> Cc: r-help@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 <dwinsem...@comcast.net> > >>>>> > >>>>> wrote: > >>>>>> > >>>>>>> From: David Winsemius <dwinsem...@comcast.net> > >>>>>>> Subject: Re: [R] 3-D response > surface > >>> > >>> using > >>>>> > >>>>> wireframe() > >>>>>>> > >>>>>>> To: "array chip" <arrayprof...@yahoo.com> > >>>>>>> Cc: r-help@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@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@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.andr...@anu.edu.au > CRICOS Provider No. 00120C > -- > http://www.neurofractal.org/felix/ >
x y z 1 0 0 1.40496188674186 2 0.25 0 0.800015588666326 3 0.5 0 0.195069290590796 4 0.75 0 -0.409877007484734 5 1 0 -1.01482330556026 6 1.25 0 -1.61976960363579 7 1.5 0 -2.22471590171132 8 1.75 0 -2.82966219978686 9 2 0 -3.43460849786239 10 2.25 0 -4.03955479593792 11 2.5 0 -4.64450109401345 12 0 2.5 1.00257090162757 13 0.25 2.5 0.369516016300772 14 0.5 2.5 -0.263538869026027 15 0.75 2.5 -0.896593754352826 16 1 2.5 -1.52964863967962 17 1.25 2.5 -2.16270352500642 18 1.5 2.5 -2.79575841033322 19 1.75 2.5 -3.42881329566002 20 2 2.5 -4.06186818098682 21 2.25 2.5 -4.69492306631362 22 2.5 2.5 -5.32797795164042 23 0 5 0.600179916513286 24 0.25 5 -0.0609835560647821 25 0.5 5 -0.72214702864285 26 0.75 5 -1.38331050122092 27 1 5 -2.04447397379898 28 1.25 5 -2.70563744637705 29 1.5 5 -3.36680091895512 30 1.75 5 -4.02796439153319 31 2 5 -4.68912786411126 32 2.25 5 -5.35029133668932 33 2.5 5 -6.01145480926739 34 0 7.5 0.197788931399 35 0.25 7.5 -0.491483128430336 36 0.5 7.5 -1.18075518825967 37 0.75 7.5 -1.87002724808901 38 1 7.5 -2.55929930791835 39 1.25 7.5 -3.24857136774768 40 1.5 7.5 -3.93784342757702 41 1.75 7.5 -4.62711548740635 42 2 7.5 -5.31638754723569 43 2.25 7.5 -6.00565960706503 44 2.5 7.5 -6.69493166689436 45 0 10 -0.204602053715285 46 0.25 10 -0.92198270079589 47 0.5 10 -1.63936334787650 48 0.75 10 -2.3567439949571 49 1 10 -3.07412464203771 50 1.25 10 -3.79150528911831 51 1.5 10 -4.50888593619892 52 1.75 10 -5.22626658327952 53 2 10 -5.94364723036013 54 2.25 10 -6.66102787744073 55 2.5 10 -7.37840852452134 56 0 12.5 -0.606993038829571 57 0.25 12.5 -1.35248227316144 58 0.5 12.5 -2.09797150749332 59 0.75 12.5 -2.84346074182519 60 1 12.5 -3.58894997615707 61 1.25 12.5 -4.33443921048894 62 1.5 12.5 -5.07992844482081 63 1.75 12.5 -5.82541767915269 64 2 12.5 -6.57090691348456 65 2.25 12.5 -7.31639614781643 66 2.5 12.5 -8.06188538214831 67 0 15 -1.00938402394386 68 0.25 15 -1.782981845527 69 0.5 15 -2.55657966711014 70 0.75 15 -3.33017748869328 71 1 15 -4.10377531027643 72 1.25 15 -4.87737313185957 73 1.5 15 -5.65097095344271 74 1.75 15 -6.42456877502585 75 2 15 -7.198166596609 76 2.25 15 -7.97176441819214 77 2.5 15 -8.74536223977528 78 0 17.5 -1.41177500905814 79 0.25 17.5 -2.21348141789255 80 0.5 17.5 -3.01518782672696 81 0.75 17.5 -3.81689423556137 82 1 17.5 -4.61860064439579 83 1.25 17.5 -5.4203070532302 84 1.5 17.5 -6.22201346206461 85 1.75 17.5 -7.02371987089902 86 2 17.5 -7.82542627973343 87 2.25 17.5 -8.62713268856784 88 2.5 17.5 -9.42883909740225 89 0 20 -1.81416599417243 90 0.25 20 -2.64398099025811 91 0.5 20 -3.47379598634379 92 0.75 20 -4.30361098242947 93 1 20 -5.13342597851515 94 1.25 20 -5.96324097460083 95 1.5 20 -6.79305597068651 96 1.75 20 -7.62287096677219 97 2 20 -8.45268596285787 98 2.25 20 -9.28250095894355 99 2.5 20 -10.1123159550292 100 0 22.5 -2.21655697928671 101 0.25 22.5 -3.07448056262366 102 0.5 22.5 -3.93240414596061 103 0.75 22.5 -4.79032772929756 104 1 22.5 -5.64825131263451 105 1.25 22.5 -6.50617489597145 106 1.5 22.5 -7.3640984793084 107 1.75 22.5 -8.22202206264535 108 2 22.5 -9.0799456459823 109 2.25 22.5 -9.93786922931925 110 2.5 22.5 -10.7957928126562 111 0 25 -2.618947964401 112 0.25 25 -3.50498013498922 113 0.5 25 -4.39101230557743 114 0.75 25 -5.27704447616565 115 1 25 -6.16307664675387 116 1.25 25 -7.04910881734208 117 1.5 25 -7.9351409879303 118 1.75 25 -8.82117315851852 119 2 25 -9.70720532910674 120 2.25 25 -10.5932374996950 121 2.5 25 -11.4792696702832
______________________________________________ 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.