gnuplotrb icon indicating copy to clipboard operation
gnuplotrb copied to clipboard

inconsistent xrange behaviour with time data

Open peterlongfield opened this issue 7 years ago • 0 comments

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/SciRuby/gnuplotrb/issues/14]

peterlongfield avatar Mar 01 '18 02:03 peterlongfield