import static com.twosigma.beakerx.groovy.widgets.Interactive.interact class DataHolder{ static Plot plot = null; } public static Object f(a,b){ if (DataHolder.plot == null){ DataHolder.plot = new Plot(title: "Lissajous Curves") } List t = (1..1000) List x = t.collect { it -> sin(it*a/100)} List y = t.collect { it -> cos(it*b/100)} DataHolder.plot.getGraphics().clear() DataHolder.plot.add(new Line(x: x, y: y)) return DataHolder.plot } interact(this.&f, 3d, -3d);