rdp / ruby_gnuplot

The ruby gnuplot gem [gnuplot] [rgnuplot] (official releases of the gnuplot gem are from rdp branch)
BSD 3-Clause "New" or "Revised" License
217 stars 48 forks source link

Provide support for starting gnuplot process and keep it running #3

Open protobits opened 14 years ago

protobits commented 14 years ago

What I mean is, provide support for doing:

gnuplot = Gnuplot.open .... gnuplot.close

This way you can start gnuplot and have the process running and do multiple graphs from different parts of your code. This avoids starting up a gnuplot process for each plotting operation.

This could be achieved by simply doing:

if (block_given?) IO::popen( cmd, "w") { |io| yield io } else IO::popen( cmd, "w")

at the openmethod

rdp commented 14 years ago

I'd be happy to accept a pull request...or if not I might get around to it eventually.

rdp commented 14 years ago

oh I see what you're saying now... something like

@io ||+ IO::popen(cmd, "w")...            
protobits commented 14 years ago

I don't understand that syntax =b

rdp commented 14 years ago

is gnuplot slow for you currently?

protobits commented 14 years ago

Hi, actually, I'm not using ruby_gnuplot for my project. I was just assessing the capabilities of your code so I could see if it would serve my needs. I ended up implemeting a very simple gnuplot interface in my ruby-gsl-ng code.

In any case, if you need to update the plot often (like I do, in a robotics simulator I developed) restarting the gnuplot process is out of the question. I've even had to resort to using binary data to speed things up.

rdp commented 13 years ago

leaving open since I think you can do multiple plots, as described...so maybe someday would make for a speedup.