{"id":13243,"library":"gnuplot","title":"node-gnuplot wrapper","description":"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.","status":"abandoned","version":"0.3.1","language":"javascript","source_language":"en","source_url":"git://github.com/davvo/node-gnuplot","tags":["javascript","gnuplot","plot"],"install":[{"cmd":"npm install gnuplot","lang":"bash","label":"npm"},{"cmd":"yarn add gnuplot","lang":"bash","label":"yarn"},{"cmd":"pnpm add gnuplot","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package is CommonJS-only and does not provide an ESM export. Use `require` for module loading.","wrong":"import gnuplot from 'gnuplot';","symbol":"gnuplot","correct":"const gnuplot = require('gnuplot');"},{"note":"The primary export is a function that, when called, spawns a new gnuplot process and returns a duplex stream.","symbol":"gnuplot()","correct":"const plotter = gnuplot();"},{"note":"Methods like `.set()`, `.plot()`, `.unset()` are available on the object returned by `gnuplot()` and can be chained.","symbol":"gnuplot.set","correct":"gnuplot().set('term png');"}],"quickstart":{"code":"const gnuplot = require('gnuplot');\nconst fs = require('fs');\n\n// Example 1: Generate a plot directly\ngnuplot()\n    .set('term png')\n    .set('output \"out.png\"')\n    .set('title \"Some Math Functions\"')\n    .set('xrange [-10:10]')\n    .set('yrange [-2:2]')\n    .set('zeroaxis')\n    .plot('(x/4)**2, sin(x), 1/x')\n    .end();\n\n// Example 2: Stream data to gnuplot\n// Assuming 'input.dat' exists and 'output.svg' is desired\n// const data = fs.createReadStream('input.dat');\n// const out = fs.createWriteStream('output.svg');\n// const plotter = gnuplot().set('term svg');\n// data.pipe(plotter).pipe(out);\n","lang":"javascript","description":"Demonstrates generating a PNG plot with chained commands and initiating a gnuplot process."},"warnings":[{"fix":"Install gnuplot on your operating system (e.g., `brew install gnuplot` on macOS, `sudo apt-get install gnuplot` on Debian/Ubuntu).","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"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.","message":"The package is CommonJS-only and does not provide an ESM (ECMAScript Module) export. Attempting to use `import` syntax will result in errors.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Evaluate alternatives if long-term maintenance, active support, or compatibility with modern Node.js features are critical for your project.","message":"This 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.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Create a `gnuplot.d.ts` file with basic type definitions, or install `@types/gnuplot` if one becomes available (unlikely for an unmaintained package).","message":"The package does not ship with TypeScript declaration files (.d.ts). Users in TypeScript projects will need to provide their own ambient type declarations.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure gnuplot is installed on your system and its executable path is included in your environment's PATH variable.","cause":"The `gnuplot` executable is not found in the system's PATH.","error":"Error: spawn gnuplot ENOENT"},{"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);`).","cause":"Attempting to use `require()` in an ES module context.","error":"ReferenceError: require is not defined"},{"fix":"Ensure all commands are sent before the stream is closed. If chaining, avoid calling `.end()` prematurely or setting `{end: true}` on intermediate commands.","cause":"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).","error":"Error: write after end"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}