npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gnu-plot

v0.3.1

Published

javascript node wrapper for gnuplot

Downloads

246

Readme

node-gnuplot

javascript node.js wrapper for gnuplot

example

var gnuplot = require('gnu-plot')
gnuplot().plot([{
    data:[[0,0],[1,1],[2,0]]
}])

Breaking changes

Note: gnuplot.exe >=v5.4 mangles stdin on my Windows machine, I recommend staying on 5.2.8

Version 0.3.0

  • plotsSettings.color renamed to plotsSettings.rgbcolor
    Fix : color:"#FF0000" -> rgbcolor:"#FF0000"

Methods

gnuplot()

Spawn a new gnuplot process and return a plot object inheriting child_process.

var plot = gnuplot()

plot.plot(plotsSettings)

Plots with plotsSettings Array.

plotsSettings

Array of plot settings objects corresponding to different data series

[{
	title:<title>,

	using:<using>,
	smooth:<smooth>,
	axes:<axes>,
	bin:<using>,

	style:<style>,
	color:<color>,
	rgbcolor:<rgbcolor>,

	data:<data>,
},...]

title

default: <index of setting object in plotsSettings array>
Title of the data serie

using

default: undefined
Used to tell gnuplot which data columns (or pseudo-column to use). Please refer to gnuplot documentation.
Can be used to handle datetime data or change missing data handling.

smooth

default: undefined
Used for interpolation and approximation of data. Please refer to gnuplot documentation.

axes

default: x1y1
Axes used for the data serie.
Choose from ["x1y1","x1y2","x2y1","x2y2"]
The axes are positionned :
- x1: bottom
- x2: top
- y1: left
- y2: right

bin

default: undefined
Used to bin data. Please refer to gnuplot documentation.
You should calculate them in JS instead of with gnuplot.

style

default: "lines"
Style of the data serie in :

lines
points
linespoints
surface
dots
impulse
boxes

see with clause of the plot command in gnuplot documentation for more.

color

shorthand for style:"linecolor <color>"
Color setting of the data serie
Used with

rgbcolor

shorthand for style:"linecolor rgbcolor \"<color>\""
Color of the data serie
by name : execute gnuplot -e "show colornames" to view all possible values
by value : #RRGGBB, #AARRGGBB

data

Data Array with structure

[[x0,y0],[x1,y1],[x2,y2], ...]

Or mathematical formula

"2*x**2+3*x+4"

Example

plot.plot([{
	title:"A",
	rgbcolor:"#00FF00",
	data:[
		[0  , 10],
		[0.5, 90],
		[1  , 85],
		[1.5, 20],
		[2  , 25]
	]
},{
	title:"B",
	rgbcolor:"red",
	style:"linespoints",
	data:[
		[0.4,30],
		[1.1,70],
		[1.8,40]
	],
},{
	title:"C",
	rgbcolor:"blue",
	data: "-2*x**2+3*x+4",
}])

plot.splot(plotsSettings)

Same as plot.plot(plotsSettings) for 3D plots

plot.set(options)

Set or unset some gnuplot options.

options

Object containing options as key:values.
See gnuplot documentation for a complete list of available options.

Notable options:

Axes label

{x|y|x2|y2|z}label:<label>

plot.set({xlabel:"'s'",yrange:"'°C'"})

Fixed axes

{x|y|x2|y2}range:"[[<min>]:[<max>]]"

plot.set({xrange:"[0:]",yrange:"[-5:5]"})

Line at origin

{x|y|x2|y2|z}zeroaxis: true

plot.set({yzeroaxis:true})

Axes tics interval

{x|mx|y|my|x2|mx2|y2|my2|z|mz}tics:<interval>

plot.set({
	xtics: 10,      // major xtic every 10
	mxtics: 2,      // 2 minor xtics per major xtic
	ytics: [
		10,         // major ytic every 10
		"add (42)", // add ytic at y=42
	],
	y2tics: true,   // show auto interval tics
})

Log scale

logscale:"[x][x2][y][y2][z] <base>"
default base : 10

plot.set({
	logscale:[
		"x",     // logscale for x axis with default base 10
		"yy2 2", // logscale for y and y2 axes with base 2
	],
})

Grid

grid: "[xtics] [mxtics] [ytics] [mytics] [ztics] [mztics] [<style>]"

plot.set({grid:"xtics ytics"})// default style
plot.set({grid:"xtics mxtics ytics mytics lines -1 dashtype 2, lines 0"}) // dashed for tics, dotted for minor tics

output to image

term:"{png|jpeg} size <x>,<y>", output:"<file>"

plot.set({term:"png size 800,600", output:"plot.png"})

output to terminal

term:"dumb [size <x> <y>]"

plot.stdout.pipe(process.stdout) //print gnuplot output to console
// plot 200 characters wide & 50 chararcters tall 
plot.set({term:"dumb 200 50"})
// or for a plot filling the terminal
plot.set({term:"dumb "+process.stdout.columns+" "+process.stdout.rows})

plot.print(string)

Write string to stdin of the gnuplot process.