This is simply...wonderful...
thankyou very much Greg!
The sfunc was not at all intuitive..so I think your example can inspire a lot of r-sig-geo community

best
paolo


________________________________
Da: Greg Snow [538280@gmail.com]
Inviato: mercoledė 17 luglio 2013 19.43
A: Paolo Piras
Cc: r-sig-geo@r-project.org
Oggetto: Re: [R-sig-Geo] R or R studio 3d manipulate

Here is an example using tkexamp and wireframe (from lattice) to do a 3d surface (based on one of the mathematica examples):

library(TeachingDemos)
library(lattice)

sfunc <- function(n=1, xx=-60, yy=0, zz=40) {
mydf <- expand.grid( x=seq(0,3, length=25),
y=seq(0,3,length=25) )
mydf$z <- with(mydf, sin( n*x*y ))
print(wireframe( z ~ x + y, data=mydf, screen=list(z=zz,y=yy,x=xx),
drape=TRUE))
}

tmp.list <- list( n=list('slider', from=1, to=5, resolution=0.1, init=1),
xx=list('slider', from=-180, to=180, resolution=5, init=-60),
yy=list('slider', from=-180, to=180, resolution=5, init=0),
zz=list('slider', from=-180, to=180, resolution=5, init=40) )

tkexamp(sfunc, tmp.list, side='left')




On Sat, Jul 13, 2013 at 5:34 PM, Paolo Piras <paolo.piras@uniroma3.it<mailto:paolo.piras@uniroma3.it>> wrote:
Hi Greg,
thankyou very much for your advice and sorry for my delay in answering you

I'm getting closer to what I have in my mind.........

this works under Rstudio dynamically *in function of zz** using your own example; z, instead, is the perspective
the graph is calculated only at any particular value of zz

zz <- seq(-10, 10, 0.01)
xx <- cos(zz)
yy <- sin(zz)
library(manipulate)
library(scatterplot3d)
manipulate(scatterplot3d(cbind(xx,yy,zz),angle=z,pch=19,type="l",xlim=range(cbind(xx,yy,zz)),ylim=range(cbind(xx,yy,zz)),zlim=range(cbind(xx,yy,zz))),zz=slider(min(zz),max(zz),step=0.01),z=slider(1,360))

I would like to do the same in tkexamp, but I cannot reprodice it in the same way....
the next step is the same but by visualizing a surface
any suggestion?

best

paolo

________________________________
Da: Greg Snow [538280@gmail.com<mailto:538280@gmail.com>]
Inviato: giovedė 11 luglio 2013 22.27

A: Paolo Piras
Cc: r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>
Oggetto: Re: [R-sig-Geo] R or R studio 3d manipulate

Here is an example that works with the scatterplot3d function (from the package of the same name).  I only found 2 arguments that control the projection, angle and scale.y:

library(scatterplot3d)
library(TeachingDemos)

# from example 1 of scatterplot3d

       zz <- seq(-10, 10, 0.01)
       xx <- cos(zz)
       yy <- sin(zz)

# controls

clist <- list( angle=list('slider', init=40, from=5, to=85, resolution=5),
scale.y = list('slider', init=1, from=0.5, to=1.5, resolution=0.1 ) )

tkexamp( scatterplot3d(xx,yy,zz), clist )


If you want a fancier plot (e.g. include more points, a plane, etc.) then you can write a function with angle and scale.y arguments that calls all the appropriate functions, then use that function with tkexamp.  If you want even more ability to rotate then you may need to switch to using the cloud function from lattice or rgl or do you own projections (or delve further into using scatterplot 3d than I have).


On Mon, Jul 8, 2013 at 10:49 AM, Paolo Piras <paolo.piras@uniroma3.it<mailto:paolo.piras@uniroma3.it>> wrote:
Hi greg
I did not know the function and it is very nice..
my problem is.....
take the  examples of the help page of  tkexamp(): they are  2d graphs where you can changes plot options; I'm pretty sure you can do what I can do in Rstudio; this an Rstudio example:

library(manipulate)
xx<-abs(rnorm(30,5,1))
yy=log(xx)
plot(xx,yy)
zz<-1/xx
manipulate( plot(xx,yy^zz,xlim=range(cbind(xx,yy*zz),ylim=range(cbind(xx,yy*zz)))), zz=slider(-1,1,step=0.1))

using the control under the small gear  button at high left corner of the graph you can change the plot **in function** of the zz parameter

I THINK it can be replicated using  tkexamp() and I will try; I did not yet because I want to answer you immediately.....

however I want to do the same things on a 3D graph;
under the help of function rotate.wireframe() I saw the closest thing to what I have in my mind.....
I tried to pass to tkexamp() threee variables using scatterplot3d() but I receive an error

it is possible to combine the potential of  tkexamp() --- or manipulate---- that allows to change the graph in function of a given values of x and the 3d visualization of rotate.wireframe() ?
This could replicate what you can see on the web address of Mathematica I posted in my previous post:
http://reference.wolfram.com/mathematica/tutorial/IntroductionToManipulate.html
I saw that under Rstudio the package "manipulate" can handle objects coming from scatterplot3d()  but the point of view remains fixed; you cannot rotate it dinamically as in a rgl scene or even in a rotate.wireframe graph; on the other hand.....I cannot find a solution to manipulate a 3d plot of a rgl scene in function of a given parameters that changes the values of x,y and z as you can possibly do in  tkexamp() or  manipulate();
The best could be to integrate the potential of tkexamp() and rotate.wireframe() together
could you indicate me the other solutions you refer in your previous message?
Anyway...thanks a lot!!
Awaiting an answer from you I will try to play with TeachinDemos more accurately
best regards
Paolo




________________________________
Da: Greg Snow [538280@gmail.com<mailto:538280@gmail.com>]
Inviato: lunedė 8 luglio 2013 17.53
A: Paolo Piras
Cc: r-sig-geo@r-project.org<mailto:r-sig-geo@r-project.org>
Oggetto: Re: [R-sig-Geo] R or R studio 3d manipulate

If you can write a function that takes the arguments that you want to change and creates the graph you want to see, then there are several tools that can be used to create controls that will change those arguments.  The `tkexamp` function in the TeachingDemos package is one such tool, but there are others as well.  If you can give a more specific example of what graph you would like and what values you would like to change then we may be able to give a more specific example.


On Thu, Jul 4, 2013 at 2:56 PM, Paolo Piras <paolo.piras@uniroma3.it<mailto:paolo.piras@uniroma3.it>> wrote:
Hi folks,

I'm performing some simulation of spatial data that I need to visualize when manipulating a given variable in expression
Do you know if there is ANY possibility to build a 3d graph with a manipulator button?
In 2d it is very easily feasable in RStudio; I did it
 but in 3D ...I cannot find any solution
I would like to do in R what you can see here (in Mathematica) under the section "3D graphics":
http://reference.wolfram.com/mathematica/tutorial/IntroductionToManipulate.html


Thanks in advance for your advice
best
paolo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org<mailto:R-sig-Geo@r-project.org>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo



--
Gregory (Greg) L. Snow Ph.D.
538280@gmail.com<mailto:538280@gmail.com>



--
Gregory (Greg) L. Snow Ph.D.
538280@gmail.com<mailto:538280@gmail.com>



--
Gregory (Greg) L. Snow Ph.D.
538280@gmail.com<mailto:538280@gmail.com>

	[[alternative HTML version deleted]]

