The WPlot class

WPlot is a Groovy class that provides convenient static methods to build plots (Note that, like Java, the Groovy language does not support functions).

A simple way to invoke these methods in MATLAB is to call them with the property name/ value pairs supplied as a MATLAB cell array - note the {} brackets below. WPlot recognizes MATLAB-style name value combinations when the input is supplied in this form.

import kcl.waterloo.plot.WPlot;
p=WPlot.scatter({'XData', 1:10, 'YData', 1:10});

This returns an instance of the WPlot class. This is merely a wrapper class equivalent to the GXPlot class in the MATLAB API. Only two instance methods are of much interest:

  • getPlot - returns a reference to the Waterloo plot instance
  • createFrame - displays the plot
To dislay the plot above call":
Note that the returned result, f, is a Waterloo GCFrame: a Swing JFrame subclass (shown to the right) and not a MATLAB figure window. The WPlot methods do not support MATLAB graphics.

Both the Java plot classes and WPlot implement the createFrame method. It is a convenience mechanism to display simple plots. Alternatively, you can use the Java library to create graph containers and add plots to them. That way you can create grids of plots.