From 5c6b0c50107ff9039a67b03171a86ce227d36779 Mon Sep 17 00:00:00 2001 From: "samanshafigh@gmail.com" Date: Wed, 4 May 2016 10:27:06 +1000 Subject: [PATCH] master: Add extra option parameters to be able to set for example x and y range --- README.md | 4 +++- plotter.js | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d5d79d1..1e03c8b 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,7 @@ The following properties can be used: - `style` : _The style of the lines on the graph. Possibilites include `lines` (default), `points` and `linespoints`_ - `nokey` : _Disables the graph key_ +- `options` : _Sets extra option parameters_ The following example shows these in use: @@ -71,7 +72,8 @@ plot({ logscale: true, xlabel: 'time', ylabel: 'length of string', - format: 'pdf' + format: 'pdf', + options: ['xrange [0:120]', 'yrange [1000:2500]'], }); ``` diff --git a/plotter.js b/plotter.js index d365941..f41b8a9 100644 --- a/plotter.js +++ b/plotter.js @@ -114,7 +114,14 @@ function setup_gnuplot(gnuplot, options) { if (options.ylabel) { gnuplot.stdin.write('set ylabel "'+options.ylabel+'"\n'); } - + + /* Set extra option parameters */ + if (options.options) { + for (var i = 0; i < options.options.length; i += 1) { + gnuplot.stdin.write('set '+options.options[i]+'\n'); + } + } + /* Setup ticks */ gnuplot.stdin.write('set grid xtics ytics mxtics\n'); gnuplot.stdin.write('set mxtics\n');