Plotting timeseries data
Opened this issue · 7 comments
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
endthe 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?
there is a ds.using = is that what you're referring to? I think maybe you found the answer to your own question :)
Yes, using ds.using makes it work. But wouldn't it be better if ruby-gnuplot would include this by default?
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
#41 (comment).
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)?
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.