Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotting timeseries data #41

Open
wvengen opened this issue Nov 23, 2015 · 7 comments
Open

Plotting timeseries data #41

wvengen opened this issue Nov 23, 2015 · 7 comments

Comments

@wvengen
Copy link

wvengen commented Nov 23, 2015

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
Copy link
Owner

rdp commented Nov 25, 2015

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

@wvengen
Copy link
Author

wvengen commented Nov 26, 2015

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

@rdp
Copy link
Owner

rdp commented Dec 7, 2015

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 [email protected] 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).

@sixtyfive
Copy link

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
Copy link
Owner

rdp commented Nov 1, 2020 via email

@sixtyfive
Copy link

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
Copy link
Owner

rdp commented Nov 5, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants