Skip to content

Commit 3324614

Browse files
committed
add example to test fit
1 parent cfb22f2 commit 3324614

5 files changed

Lines changed: 1018 additions & 0 deletions

File tree

6.96 KB
Loading
6.96 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
set term png size 600,600
2+
set output './gnuplot.png'
3+
a = 1
4+
b = 1
5+
set xrange [0:5]
6+
fit a*x*x + b 'points.data' using 1:2:3 zerror via a,b
7+
unset xrange
8+
plot a*x*x+b title 'Fit formula', 'points.data'
9+
unset output

‎examples/plot_fit_result/plot.rb‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require 'gnuplotrb'
2+
include GnuplotRB
3+
4+
fit_result = fit('points.data', using: '1:2:3', function: 'a*x*x + b', initials: { a: 1, b: 1 }, term_options: { xrange: 0..5 })
5+
6+
plot = Plot.new(fit_result[:formula_ds], fit_result[:data])
7+
8+
plot.to_png('./gnuplot_gem.png', size: [600, 600])

0 commit comments

Comments
 (0)