Registry / data / gnuplot

gnuplot

JSON →
library0.3.1jsnpmunverified

node-gnuplot is a lightweight wrapper for the `gnuplot` command-line utility, designed for Node.js environments. Currently at version 0.3.1, this package provides a direct and programmatic interface to interact with the external `gnuplot` plotting engine. It allows developers to send `gnuplot` commands, such as `set`, `plot`, and `splot`, via a fluent, chainable API or by piping data streams directly. The library spawns a `gnuplot` child process and manages its stdin/stdout, making it suitable for generating image files (e.g., PNG, SVG) from mathematical functions or data streams. Its release cadence is slow, and the package appears to be in an abandoned state given its low version number and lack of recent activity. A key differentiator is its minimal abstraction over `gnuplot`, providing direct access to its capabilities rather than implementing its own charting logic. Users must have `gnuplot` installed on their system for this package to function.

npm install gnuplot
INSTALL
IMPORT
SIG · GNUPLOT
G
gnuplot
datajavascriptv0.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

gnuplot
const gnuplot = require('gnuplot');
import gnuplot from 'gnuplot';
This package is CommonJS-only and does not provide an ESM export. Use `require` for module loading.
gnuplot()
const plotter = gnuplot();
The primary export is a function that, when called, spawns a new gnuplot process and returns a duplex stream.
gnuplot.set
gnuplot().set('term png');
Methods like `.set()`, `.plot()`, `.unset()` are available on the object returned by `gnuplot()` and can be chained.

Demonstrates generating a PNG plot with chained commands and initiating a gnuplot process.

const gnuplot = require('gnuplot'); const fs = require('fs'); // Example 1: Generate a plot directly 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(); // Example 2: Stream data to gnuplot // Assuming 'input.dat' exists and 'output.svg' is desired // const data = fs.createReadStream('input.dat'); // const out = fs.createWriteStream('output.svg'); // const plotter = gnuplot().set('term svg'); // data.pipe(plotter).pipe(out);
Debug
Known issues
gotchaThis package is a wrapper around the `gnuplot` command-line utility. You must have `gnuplot` installed and accessible in your system's PATH for this package to function correctly.
fix
Install gnuplot on your operating system (e.g., `brew install gnuplot` on macOS, `sudo apt-get install gnuplot` on Debian/Ubuntu).
affects: >=0.1.0
gotchaThe package is CommonJS-only and does not provide an ESM (ECMAScript Module) export. Attempting to use `import` syntax will result in errors.
fix
Use `const gnuplot = require('gnuplot');` to import the module in CommonJS environments. For ESM projects, you might need a wrapper or a CommonJS compatibility layer.
affects: >=0.1.0
gotchaThis package is at version 0.3.1 and appears to be largely unmaintained. It may not receive updates for new Node.js versions, security vulnerabilities, or bug fixes.
fix
Evaluate alternatives if long-term maintenance, active support, or compatibility with modern Node.js features are critical for your project.
affects: >=0.1.0
gotchaThe package does not ship with TypeScript declaration files (.d.ts). Users in TypeScript projects will need to provide their own ambient type declarations.
fix
Create a `gnuplot.d.ts` file with basic type definitions, or install `@types/gnuplot` if one becomes available (unlikely for an unmaintained package).
affects: >=0.1.0
Errors
Common errors & fixes
Error: spawn gnuplot ENOENT
The `gnuplot` executable is not found in the system's PATH.
fix
Ensure gnuplot is installed on your system and its executable path is included in your environment's PATH variable.
ReferenceError: require is not defined
Attempting to use `require()` in an ES module context.
fix
This package is CommonJS-only. If running in an ESM environment, you may need to wrap its usage in a CommonJS context or use dynamic `import()` for compatibility if supported by your runtime (e.g., `const gnuplot = await import('gnuplot').then(m => m.default || m);`).
Error: write after end
Attempting to write to the gnuplot process stream after it has been explicitly or implicitly closed (e.g., by calling `.end()` or passing `{end: true}` to a command).
fix
Ensure all commands are sent before the stream is closed. If chaining, avoid calling `.end()` prematurely or setting `{end: true}` on intermediate commands.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
gnuplot — npm install gnuplot · libregistry