Tag: gnuplot

使用gnuplot在节点js中绘制和保存数字

我在节点js的bashsubprocess中使用gnuplot来绘制一些数据并保存graphics。 这是我的代码到目前为止: var term = require('child_process').spawn('bash'); term.stdin.write('gnuplot -p\n'); term.stdin.write('set key outside\n'); term.stdin.write('set term png\n'); term.stdin.write('set output "plot1.png"\n') term.stdin.write('plot for [col=2:4] "results" using 1:col with points title columnheader\n'); term.stdin.write('set output "plot2.png"\n') term.stdin.write('plot for [col=5:7] "results" using 1:col with points title columnheader\n'); 这是更正确和最快的方式吗? 无论如何,我可以使它更紧凑和简单? 另外,当我在node.js脚本中运行这个脚本时,当我运行这个脚本的时候,这个脚本不会退出。 如何解决这个问题?

pipe道到一个spawn stdin

我想pipe一些stream数据到feedgnuplot为了实时绘制它 以下工作: // index.js readableStream.pipe(process.stdout) // in bash $ node index.js | feedgnuplot –stream 但是下面的行不通(这就是我想要做的): // index.js var feedgnuplot = require('child_process').spawn('feedgnuplot', ['–stream']) readableStream.pipe(feedgnuplot.stdin) //in bash $ node index.js 我收到ECONNRESET错误 编辑:请求可读stream的示例: var util = require('util') var Readable = require('stream').Readable util.inherits(SomeReadableStream, Readable) function SomeReadableStream () { Readable.call(this) } SomeReadableStream.prototype._read = function () { this.push(Math.random().toString()+'\n') } var someReadableStream […]