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
216 stars 48 forks source link

Plotting timeseries data #41

Open wvengen opened 8 years ago

wvengen commented 8 years ago

How can timeseries data best be plotted using this gem?

When using

require 'gnuplot'

Gnuplot.open do |gp|
  Gnuplot::Plot.new(gp) do |plot|
    plot.xdata :time
    plot.timefmt '"%s"'
    plot.format 'x "%H:%m"'

    plot.data << Gnuplot::DataSet.new( [[Time.now, Time.now + 60], [1, 2]] ) do |ds|
      ds.with = "linespoints"
      ds.title = "Howdy"
    end
  end
end

the errors I get are:

gnuplot> plot '-' title 'Howdy' with linespoints
                                                ^
         line 0: Need full using spec for x time data

gnuplot> 2015-11-23 18:46:14 +0100 1
         ^
         line 0: invalid command

gnuplot> 2015-11-23 18:47:14 +0100 2
         ^
         line 0: invalid command

Workaround: add ds.using = '1:2' to the dataset. Would it be better if this gem includes a default using for each dataset?

See also http://stackoverflow.com/a/18121824/2866660

rdp commented 8 years ago

there is a ds.using = is that what you're referring to? I think maybe you found the answer to your own question :)

wvengen commented 8 years ago

Yes, using ds.using makes it work. But wouldn't it be better if ruby-gnuplot would include this by default?

rdp commented 8 years ago

Hmm...I don't understand the internal workings enough of gnuplot to understand this enough to know exactly what to do here. However, I will definitely leave this thread up so that followers can use your tips to figure it out, thank you!

On Thu, Nov 26, 2015 at 2:50 AM, wvengen notifications@github.com wrote:

Yes, using ds.using makes it work. But wouldn't it be better if ruby-gnuplot would include this by default?

— Reply to this email directly or view it on GitHub https://github.com/rdp/ruby_gnuplot/issues/41#issuecomment-159861704.

sixtyfive commented 3 years ago

Now, 5 years later, that same code only results in this for me:

Warning: empty x range [2020:2020], adjusting to [1999.8:2040.2]
Warning: empty y range [0:0], adjusting to [-1:1]

Could that be due to the newer Gnuplot (5.2)?

rdp commented 3 years ago

According to the initial conversation it just want supported yet?

On Saturday, October 31, 2020, J. R. Schmid notifications@github.com wrote:

Now, 5 years later, that same code only results in this for me:

Warning: empty x range [2020:2020], adjusting to [1999.8:2040.2] Warning: empty y range [0:0], adjusting to [-1:1]

Could that be due to the newer Gnuplot (5.2)?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.< https://ci6.googleusercontent.com/proxy/11j4rlnZLUXOFd1lQ3MJyDzCULJaFYnbQTuLOeLGAUwgrbAeBuqPZ7NEEHAWn5AOj3LOxMQaXHecqhUKSdI3dn-t-EgC1B0j3KKyxNybJz70_rsMVzXoRikUdEM3FojDKMwwsU-ymk2fFbj3NKZWVmVqWejYN5l7MssXdMaz1R7w1IFj7x7qmVKCoRJByQih59dPnyQKns-uanOq29_YyLlel2Q6YackLONB3NhN7g=s0-d-e1-ft#https://github.com/notifications/beacon/AAADBUEJDKESUEFAEEDCL7DSNSL2HA5CNFSM4BU642C2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFLVFPQY.gif>

sixtyfive commented 3 years ago

No, gnuplot supports timeseries data just fine. And as I understand the initial description of this Issue here, it also used to work with ruby_gnuplot, if only you didn't forget an appropriate ds.using. That doesn't seem to be the case anymore though.

rdp commented 3 years ago

Yeah it should still work with using. Just no native option yet.

On Saturday, October 31, 2020, J. R. Schmid notifications@github.com wrote:

No, gnuplot supports timeseries data just fine. And as I understand the initial description of this Issue here, it also used to work with ruby_gnuplot, if only you didn't forget an appropriate ds.using. That doesn't seem to be the case anymore though.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.< https://ci3.googleusercontent.com/proxy/dTrFX0xUWsKFAgpG2_PXfJpy8s4Lt2UsEtZixHAbxqhsoMk9G64GkrrzHpZJhTMyUyUcV8utgQVnM68eIY3s3TuAssXOMkIzW-8JKjQra7xopewI8Z-jadse4n3Rw65h9BMVz9lc6zwtXya4NOEzvOjj_BulqbCQk6cBUFxj0Rzr02hp-E2H2waVII0huVqrIvzEfkf3JPhjh61tdZ9ybe2bf8UIA4NpjT28rfEBJA=s0-d-e1-ft#https://github.com/notifications/beacon/AAADBUEBX2KUPQURCBCA3CLSNTCMLA5CNFSM4BU642C2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFLVJN3A.gif>