javascript node.js wrapper for gnuplot
var gnuplot = require('gnu-plot')
gnuplot().plot([{
data:[[0,0],[1,1],[2,0]]
}])
Spawn a new gnuplot process and return a plot object inheriting child_process.
var plot = gnuplot()
Plots with plotsSettings Array.
Array of plot settings objects corresponding to different data series
[{
title:<title>,
style:<style>,
color:<color>,
axes:<axes>,
data:<data>,
},...]
default: <index of setting object in plotsSettings array>
Title of the data serie
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.
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
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
Data Array with structure
[[x0,y0],[x1,y1],[x2,y2], ...]
plot.plot([{
title:"A",
color:"#00FF00",
data:[
[0 , 10],
[0.5, 90],
[1 , 85],
[1.5, 20],
[2 , 25]
]
},{
title:"B",
color:"red",
style:"linespoints",
data:[
[0.4,30],
[1.1,70],
[1.8,40]
]
}])
Same as plot.plot(plotsSettings)
for 3D plots
Set or unset some gnuplot options.
Object containing options as key:values.
See gnuplot documentation for a complete list of available options.
Notable options:
{x|y|x2|y2}range:"[[<min>]:[<max>]]"
plot.set({xrange:"[0:]",yrange:"[-5:5]"})
{x|y|x2|y2}zeroaxis: true
plot.set({yzeroaxis:true})
term:"{png|jpeg} size <x>,<y>", output:"<file>"
plot.set({term:"png size 800,600", output:"plot.png"})
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})
Write string to stdin of the gnuplot process.