Inherits from:: Object
This class allows you to use the powerful plotting capabilities of GNUPlot from within SuperCollider.
You need to have GNUPlot installed in order to be able to use this class!
- Example -
// plot example GNUPlot.plot( [0,2,3,2,1,0.4] ); // using the Collection extensions you can also directly use gnuplot on the array: [0,2,3,2,1,0.4].gnuplot;
Env.perc.gnuplot; Env.perc(0.1, 1.5).gnuplot; Env.adsr.gnuplot;
GNUPlot can display its plots in various ways - this quark assumes that you want to plot in Aquaterm. If you want to send plots to X11 instead, run code similar to:
// for mac users who want X: GNUPlot.initCode = GNUPlot.initCode ++ "\n set term x11 \n"; GNUPlot.gnuplotpath = GNUPlot.pathToXLauncher.quote + "/opt/local/bin/gnuplot";
- Example -
// 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
g = GNUPlot.new;
g.plot3([[0,0,0], [1,0,0], [1,1,1], [2,1,2], [3,3,2], [4,5,4]], "wiggle");
g.plot3({ { 1.0.bilinrand }.dup(3) }.dup(1000), "hairball");
// more plot3
(
h = GNUPlot.new;
t = 2*pi*Array.series(1001, 0, 1/1000);
)
( // helix
var f1 = 10;
var f2 = 10;
d = [sin(f1*t), cos(f2*t), t].flop;
h.plot3(d, \spiral)
)
( // wound wiggle
var f1 = 2;
var f2 = 3;
d = [sin(f1*t), cos(f2*t), t].flop;
h.plot3(d, 'wiggly spiral')
)
( // damped helix
var f1 = 10;
var f2 = 10;
d = [sin(f1*t)*exp(t.neg), cos(f2*t)*exp(t.neg), t].flop;
h.plot3(d, \damped)
)
g = GNUPlot.new;
g.surf3([[[0,0.5,0], [ 0.5,0,0], [ 1,-0.5,0]], [[ 0.5,1,0], [ 1,0.5,0], [ 1.5,0,0]], [[ 1,1.5,0.5], [ 1.5,1,0.5], [ 2,0.5,0.5]]], "deckchair", pm3d: false);
~xyz = (-10, -9.5 .. 10).collect{|x| (-10, -9.5 .. 10).collect{|y| [x,y,sin(x+y)] } }
g.surf3(~xyz, "undulathon", pm3d: true);
h = GNUPlot.new; // scatter wants pairs of values [x,y] // some 2d random distributions ( d = {[1.0.sum3rand, exprand(0.001, 1.0)]}.dup(1000); h.scatter(d, 'y: exp/x: qgauss') ) ( d = {{1.0.sum3rand}.dup(2)}.dup(1000); h.scatter(d, '2d quasi-gaussian') ) // walking-stick map (see Henon map) ( var gam, del, eps, ab, numit, wsm, res; wsm = {|gamma, delta, eps, ab| var anp1, bnp1; #a, b = ab; anp1 = gamma * a * (1 - a) - b; bnp1 = (delta * b - eps) * (1 - (2 * a)); [anp1, bnp1] }; gam = 3.8; del = 0.4; eps = 0.02; numit = 1000; res = Array.new(numit+1); res = res.add([0.8, 0.00001]); numit.do {|i| res = res.add(wsm.value(gam, del, eps, res[i])); }; h.scatter(res, \wsm); )
g.sendCmd("set title \"Ooo look at this\""); g.sendCmd("replot");
g = GNUPlot.new; // one channel of random value data, at 0.3 seconds interval 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;
This helpfile was created with the class HelpFile2