Patches: Browse | Submit New | Admin

[#11102] patch to solve inconsistency in verbatim data separation handling

Date:
2007-05-24 21:44
Priority:
3
Submitted By:
zs h (zursng)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
patch to solve inconsistency in verbatim data separation handling

Detailed description
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

Add A Comment: Notepad

Please login


Followup

Message
Date: 2009-07-16 13:03
Sender: Roger Pack

if this is still a problem could you file an issue
at http://github.com/rogerdpack/ruby_gnuplot/tree/master ? (though
not the original creator, I'm going to upkeep a maintained branch
there).
Thanks
Date: 2008-05-07 23:24
Sender: Michael Schuh

I found that 

131c131
<       io << v.compact.join("e\n")
---
>       io << v.compact.join("\n") <<
"\n# This is the end of set of plot commands.\n"

Worked better than the 2007-05-24 diff's submitted by zursng.
You can see what is going on by adding and doing:

44a45,48
>     # Use the next line with: setenv RB_GNUPLOT " tee
-a /tmp/gp | /usr/bin/gnuplot"
>     # to get a log file at /tmp/gp of the commands sent
to gnuplot.
>     cmd = ENV['RB_GNUPLOT']
>     puts "Cmd = #{cmd}  ",ENV['RB_GNUPLOT']

Michael Schuh

Attached Files:

Name Description Download
gnuplot.rb.diff Download

Changes:

Field Old Value Date By
File Added2027: gnuplot.rb.diff2007-05-24 21:44zursng