(function() { load("Motif") X = XApplication("dual_dev", title="Multiple Graphics Devices") rc = Widget("rc","XmPanedWindow", X@widget,realize=T) draw.a = Widget("draw1","XmDrawingArea", rc) draw.b = Widget("draw2","XmDrawingArea", rc) draw.c = Widget("draw3","XmDrawingArea", rc) XRealize(X) # Coerce each of the drawing area widgets into # graphics devices and store the device objects d = as.Device(draw.a) e = as.Device(draw.b) f = as.Device(draw.c) assign("dev1",d,where=X@frame) assign("dev2",e,where=X@frame) # Now plot things in each of the devices setDevice(d) plot(1:100) title("D") setDevice(e) plot(1:10) title("E") setDevice(f) plot(rnorm(100)) title("F") # Next, we setup callbacks which the user invokes # to have the application do things. # The basic input is if there is a mouse or keyboard event # in the first device. Callback(Quote({setDevice(dev1);plot(1:n);setDevice(dev2);plot(rnorm(n*5));n<-n+1}),draw.a, "input") assign("n",1,where=X@frame) invisible(return(X)) })()