Plotrobber
A prettier DSL for Gnuplot and Ruby.
Don’t write this:
Gnuplot.open do |gp|
Gnuplot::Plot.new( gp ) do |plot|
plot.xrange "[-10:10]"
plot.title "Sin Wave Example"
plot.ylabel "sin(x) and cos(x)"
plot.xlabel "x"
plot.data << Gnuplot::DataSet.new("sin(x)") do |ds|
ds.with = "lines"
ds.linewidth = 4
end
plot.data << Gnuplot::DataSet.new("cos(x)") do |ds|
ds.with = "lines"
ds.linewidth = 2
end
end
end
Do write this:
require 'plotrobber'
plotting {
plot('Sine Wave Example') {
xlabel 'x'
xrange '[-10:10]'
ylabel 'sin(x)'
show 'sin(x)', with: 'lines', linewidth: 4
show 'cos(x)', with: 'lines', linewidth: 2
}
}
Even more convenient:
plot('Fit some data') {
fn = fit SOME_DATA, [1,3] # Find linear fit using columns 1 and 3.
show fn # Plots the line of best fit
candlesticks SOME_DATA # Plots candlesticks using 1:3:2:6:5
}
Installation
The usual:
gem 'plotrobber'
Why “plotrobber”?
Plot for gnuplot. Robber. Robbe. Robb. Rob. Rb. Ruby.