Pulling my hair for the last few hours. Using GnuplotRB. Trying to plot some time series, and whatever formatting and xrange options I try to use, the X-axis always display 1990 to 2035 (where does this come from??)
Example below with similar data
require 'gnuplotrb'
include GnuplotRB
x = ["2013-05-22 02:49:49", "2013-05-22 02:56:49", "2013-05-22 02:56:59"]
y = [ 2,5,9]
p x.first
p x.last
element = Dataset.new(
[x, y],
with:'lines lw 3 lt rgb "black"',
timefmt: "%Y-%m-%d %H:%M:%S",
xdata: 'time',
format_x: "%Y-%m-%d %H:%M:%S",
# xrange: '[ "#{x.first}":"#{x.last}" ]'
xrange: '[ "2013-05-22 02:49:00" : "2013-05-22 02:50:00" ]'
)
myBRTraces = Plot.new(
element
)
p myBRTraces.inspect
myBRTraces.to_png("/media/sf_D_DRIVE/Test/a.svg", size: [1200, 1800], truecolor:true)
[Edit] - simplified code further.
I have also done this tweak to actually get some error logging from gnuplot. And I helps indeed pinpointing that xrange is a b*** but I still don't get how to make it work :
$ ruby test.rb
"2013-05-22 02:49:49"
"2013-05-22 02:56:59"
"#<GnuplotRB::Plot:0x00000001ba21f0 @options=Hamster::Hash[], @datasets=Hamster::Vector[#<GnuplotRB::Dataset:0x00000001ba2100 @type=:datablock, @data=#<GnuplotRB::Datablock:0x00000001ba1f70 @stored_in_file=false, @data=\"2013-05-22 02:49:49 2\\n2013-05-22 02:56:49 5\\n2013-05-22 02:56:59 9\">, @options=Hamster::Hash[:with => \"lines lw 3 lt rgb \\\"black\\\"\", :timefmt => \"%Y-%m-%d %H:%M:%S\", :xdata => \"time\", :format_x => \"%Y-%m-%d %H:%M:%S\", :xrange => \"[ \\\"2013-05-22 02:49:00\\\" : \\\"2013-05-22 02:50:00\\\" ]\"]>], @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 ("Warning: empty x range [2013:2013], adjusting to [1992.87:2033.13]"): "Warning: empty y range [2:2], adjusting to [1.98:2.02]; gnuplot> plot $DATA1 with lines lw 3 lt rgb "black" timefmt "%Y-%m-%d %H:%M:%S" xdata time format x "%Y-%m-%d %H:%M:%S" xrange [ "2013-05-22 02:49:00" : "2013-05-22 02:50:00" ]; 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'
I don't get the "Warning: empty x range [2013:2013]"
xange( must bexrange), and the xrange must be given in the same format that you use astimefmt- Christoph