(function() { load("Plot") # create the x application X = XApplication("plot", "plot.defaults") # create a plotting widget using the X application # as the parent plot.w <- Widget("3Dplot","Scat3D", X@widget, realize=T) XRealize(X) # realize the widgets # and start the event handling # put some data in the plot by calling the # S interface to the 3DScat convenience functions M = matrix(rnorm(300),100,3) dimnames(M) = list(NULL,c("M-X", "M-Y", "M-Z")) Scat3D(M, plot.w, xlab="X",zlab="Z", xlim=c(-2.1,2.1), ylim=c(-2.1,2.1) ,zlim=c(-5.1,5.1) ) invisible(return(X)) })()