From: Axel Friedrich Date: 2013-06-13T03:35:02+09:00 Subject: Re: Replot in ruby gnuplot Hi Lars, > I need to plot data in real time, reading a file over and over and > update a the screen. How to implement reread and replot? Are you on Windows? Or, which OS? I do something similar as you want to do (on Windows): I write data coming from an ADC to Disk (using a c-programm), update line by line each 1..60 seconds, and I read this file with Ruby and send the data from Ruby to gnuplot, doing 2d-plots, updating the plot each time Ruby reads a new data line. For reading the file I use: file-tail. For "real-time" plotting with gnuplot I took a lot from here and transfered it to Ruby: * http://users.softlab.ece.ntua.gr/~ttsiod/gnuplotStreaming.html * http://www.lysium.de/blog/index.php?/archives/234-Plotting-data-with-gnuplot-in-real-time.html * https://news.ycombinator.com/item?id=3210793 I open a pipe to pgnuplot.exe: @gp = "path_to_pgnuplot.exe" ... @pipe = IO.popen(@gp, "w") sleep 2 @pipe.puts "set xtics\n" @pipe.puts "set ytics\n" @pipe.puts "set style data #{ @linestyle }\n" @pipe.puts "set grid\n" ... @pipe.puts "plot \"-\" title 'CH1', \"-\" title 'CH2', \"-\" title 'CH3', \"-\" title 'CH4', \"-\" title 'CH5'" ... @pipe.close On Windows, I have a timeout problem with gnuplot; # "Anti-timeout" workaround; put this at the very beginning of your programm puts "Starting dummy-instance of wgnuplot" tmppipe = IO.popen(@gp, "w") sleep 10 tmppipe.close Hope it helps, Axel -- Posted via http://www.ruby-forum.com/.