gnuplot

0.3.1 • Public • Published

node-gnuplot

A super-thin wrapper around gnuplot for node.js

example

var gnuplot = require('gnuplot');
gnuplot()
    .set('term png')
    .set('output "out.png"')
    .set('title "Some Math Functions"')
    .set('xrange [-10:10]')
    .set('yrange [-2:2]')
    .set('zeroaxis')
    .plot('(x/4)**2, sin(x), 1/x')
    .end();

You can use streams!

var data = fs.createReadStream('input.dat'),
    out = fs.createWriteStream('output.svg'),
    plotter = gnuplot().set('term svg');
    
data.pipe(plotter).pipe(out);

methods

var gnuplot = require('gnuplot')

gnuplot()

Spawn a new gnuplot process and return a duplex stream combining stdout and stdin.

gnuplot.print(data, options={})

Write data to stdin of the gnuplot process. If the stream should be closed after the write, pass {end: true} as options.

gnuplot.println(data, options={})

Same as gnuplot.print(data + '\n', options)

gnuplot.set(data, options={})

Same as gnuplot.println('set ' + data, options)

gnuplot.unset(data, options={})

Same as gnuplot.println('unset ' + data, options)

gnuplot.plot(data, options={})

Same as gnuplot.println('plot ' + data, options)

gnuplot.splot(data, options={})

Same as gnuplot.println('splot ' + data, options)

gnuplot.replot(data='', options={})

Same as gnuplot.println('replot ' + data, options)

All of the above functions returns the gnuplot object and can be chained together:

gnuplot()
    .set('term png')
    .unset('output')
    .plot('[-6:6] sin(x)')
    .end();

To automatically call end() on the input stream after a command, pass {end: true} as options:

gnuplot()
    .set('term png')
    .unset('output')
    .plot('[-6:6] sin(x)', {end: true})
    .pipe(fs.createWriteStream('out.png'));

install

With npm do:

npm install gnuplot

You need to have gnuplot installed. On OSX you can do this with homebrew:

brew install gnuplot

license

ISC

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.3.1
    248
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.3.1
    248
  • 0.3.0
    0
  • 0.2.0
    1
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i gnuplot

Weekly Downloads

249

Version

0.3.1

License

ISC

Last publish

Collaborators

  • davvo