Creating Charts

The Groovy API is plot-centric and provides convenience methods for creating plots then displaying them simply by calling the createFrame() method.
                    import kcl.waterloo.plot.WPlot
                    p=WPlot.scatter(['XData', 1..10, 'YData', 1..10])
In this example, the code creates a WPlot instance. The WPlot class is just a wrapper class to which some convenience methods have been attached. One of these, createFrame, provides a thread-safe method to create a chart to house the plot.

Although the Waterloo Groovy API is plot-centric, Groovy is not. That means you can work with Swing, SwingBuilder, JavaFX, GroovyFX etc directly but still use the Waterloo Groovy API to build the plots:

                import javax.swing.JFrame
                import kcl.waterloo.plot.WPlot
                JFrame f=new JFrame()
                GJGraphContainer g=GJGraphContainer.createInstance(GJGraph.createInstance())
                p=WPlot.scatter(['XData', 1..10, 'YData', 1..10])
The code above can be run in an instance of the Groovy Console. Note, however, that:
  1. This example code is not thread-safe while the earlier code using the WPlot createFrame method was.
  2. Waterloo needs to be added to the class path as described here