the problem in general is that two consecutive plot of 2d array data in a single piped into the same gnuplot process
would cause the 1st sentence of the 2nd plot (usually a `set' command) useless, due to the inconsistency in handling
verbatim data ending in gnuplot.rb.
consider the following case:
----------------------------------------------------------------------
require 'gnuplot'
def gmultiplot(*plots)
Gnuplot.open do |gp|
gp.puts "set multiplot\n"
plots.each do |origin, size, hook|
Gnuplot::Plot.new(gp) do |each_mp|
each_mp.origin origin.join(", ")
each_mp.size size.join(", ")
end
hook.call(gp)
end
gp.puts "unset multiplot\n"
end
end
hook=lambda{|gp|
Gnuplot::Plot.new(gp){ |pl|
pl.data << Gnuplot::DataSet.new([a=(1..10).to_a, a])
}
}
size=[0.45,1]
gmultiplot([[0,0],size,hook], [[0.5,0],size,hook])
-----------------------------------------------------------------------
==> two plot overlapped because the `set origin' command would have a leading `e' supposed to end data of the 1st
plot
the diff attached moves all verbatim data ending handling (`\ne\n') to DataSet#to_gplot |