GNUPlot class to interface GNUPlot from SuperCollider


Inherits from: Object


You need to have GNUPlot installed in order to be able to use this class!


Creation / Class Methods


*plot( arg data )

Plot the data which should be an array.

// plot example

GNUPlot.plot( [0,2,3,2,1,0.4] );

// using the Collection extensions you can also directly use plot on the array:

[0,2,3,2,1,0.4].plot;


*new

This creates an instance of GNUPlot, and a Pipe interface to pass on new plot data to it.


// create an instance and plot data:

g = GNUPlot.new;

g.plot( [0,2,3,2,1,0.4] );

// plot several sets of data in one figure:

g.plot( [ [0,2,3,2,1,0.4], [2,1,2,-2,0.4,0.2] ], 2 )

g.stop


Accessing Instance and Class Variables

plot(arg data, ns, label)

Plots the data, assuming ns rows, and using the label. This method uses a temporary file to pass on the data to GNUPlot.

g = GNUPlot.new;

// plot several sets of data in one figure:

g.plot( [ [0,2,3,2,1,0.4], [2,1,2,-2,0.4,0.2] ], 2, "example" )

g.stop

plotd(arg data, ns, label)

Plots the data, assuming ns rows, and using the label. This method pipes the data directly to GNUPlot, without using a temporary file.

setXrange( arg min, max )

Sets the x-range for the data.

setYrange( arg min, max )

Sets the y-range for the data.

stop

Stops the instance and closes the pipe.

monitor( arg updateF,dt,length,ns=1,skip=1 )

Creates a monitor for data.

updateF - update function; this should return the additional data to be plotted.

dt  - time interval between updates

length  - the number of data points to plot

ns  - the number of rows in the data

skip  - how many updates are in between plots. If skip is 1 then every dt there is a new plot. If skip=10, then every ten updates of the data, it is actually plotted. This allows you to keep the graphical update rate lower than the data update rate.

startMonitor

Start the monitor.

stopMonitor

Start the monitor.

Example: monitoring data:

In some cases it is useful to monitor data as it comes in.


// what this example does

g = GNUPlot.new;

g.monitor( { 1.0.rand; }, 0.3, 20, 1 );

g.startMonitor;

g.stopMonitor;

// monitor two values in one plot:

g.monitor( { [1.0.rand, 2.0.rand] }, 0.3, 20, 2 );

g.startMonitor;

g.stopMonitor;

// clean up:

g.stop;