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

inconsistent xrange behaviour with time data #19

Open
peterlongfield opened this issue Mar 1, 2018 · 0 comments
Open

inconsistent xrange behaviour with time data #19

peterlongfield opened this issue Mar 1, 2018 · 0 comments

Comments

@peterlongfield
Copy link

peterlongfield commented Mar 1, 2018

I have simplified an example as far as I could :

require 'gnuplotrb'
include GnuplotRB

#x = ["2013-05-22 02:49:49",    "2013-05-22 02:56:49", "2013-05-22 02:56:59"]
x = ["2012-05-22",    "2013-05-21", "2013-05-22"]
y = [ 2,5,9]

p x.first
p x.last

element = Dataset.new(
      [x, y], 
      with:'lines lw 3 lt rgb "black"', 
      xdata: 'time',
      timefmt: "%Y-%m-%d",           # timefmt: "%Y-%m-%d %H:%M:%S",
      xrange: '["2012-05-22":"2013-05-22"]'    #xrange: '["#{x.first}" : "{x.last}" ]'
      )
   
myBRTraces = Plot.new(
      element
       )
      
p myBRTraces.inspect
myBRTraces.to_png("/media/sf_D_DRIVE/Test/a.svg", size: [1200, 1800], truecolor:true)

behaviour:

 $ ruby test.rb 
"2012-05-22"
"2013-05-22"
"#<GnuplotRB::Plot:0x00000001bbe058 @options=Hamster::Hash[], @datasets=Hamster::Vector[#<GnuplotRB::Dataset:0x00000001bbdf68 @type=:datablock, @data=#<GnuplotRB::Datablock:0x00000001bbdc98 @stored_in_file=false, @data=\"2012-05-22 2\\n2013-05-21 5\\n2013-05-22 9\">, @options=Hamster::Hash[:with => \"lines lw 3 lt rgb \\\"black\\\"\", :xdata => \"time\", :timefmt => \"%Y-%m-%d\", :xrange => \"[\\\"2012-05-22\\\":\\\"2013-05-22\\\"]\"]>], @cmd=\"plot \">"
/var/lib/gems/2.3.0/gems/gnuplotrb-0.4.0/lib/gnuplotrb/mixins/error_handling.rb:28:in `check_errors': Error in previous command ("gnuplot> plot $DATA1 with lines lw 3 lt rgb "black" xdata time timefmt "%Y-%m-%d" xrange ["2012-05-22":"2013-05-22"]"): "line 4: unexpected or unrecognized token" (GnuplotRB::GnuplotError)
	from /var/lib/gems/2.3.0/gems/gnuplotrb-0.4.0/lib/gnuplotrb/staff/terminal.rb:183:in `close'
	from /var/lib/gems/2.3.0/gems/gnuplotrb-0.4.0/lib/gnuplotrb/plot.rb:85:in `plot'
	from /var/lib/gems/2.3.0/gems/gnuplotrb-0.4.0/lib/gnuplotrb/mixins/plottable.rb:111:in `to_specific_term'
	from /var/lib/gems/2.3.0/gems/gnuplotrb-0.4.0/lib/gnuplotrb/mixins/plottable.rb:53:in `method_missing'
	from test.rb:25:in `<main>'

Note : I have tweaked plot.rb as per [https://github.com//issues/14]

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

1 participant