Skip to content

inconsistent xrange behaviour with time data #19

Open
@peterlongfield

Description

@peterlongfield

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]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions