• Trouble setting xrange when x is a time

    From stuart.kendrick.sea@gmail.com@21:1/5 to All on Fri Sep 27 06:23:30 2019
    BRIEF
    I would like to pull a single day out of my multi-week data file. So I'm using 'set xrange'. But I'm stumbling on the format: gnuplot fails with
    C:\Temp\Plot>gnuplot wst-a-rtr.gp
    "wst-a-rtr.gp" line 32: Can't plot with an empty x range!

    In the config file below, uncommenting either 'set xrange' line results in the above error. Leaving them both commented out results in a beautiful chart


    DETAIL
    Data File:
    Date Time Transmitted Dropped
    2019-09-13 05:21:56 44337071 524986
    2019-09-13 05:25:01 44338275 524986
    2019-09-13 05:30:02 44340129 524986
    2019-09-13 05:35:01 44341967 524986
    2019-09-13 05:40:02 44343952 525104
    [...]


    Config File:
    # Define variables
    long_title = 'COPP Drops across Time'
    data_file = 'wst-a-rtr-log.txt'
    output_file = 'wst-a-rtr.png'

    # File specifics
    set datafile sep whitespace
    set output output_file

    # Chart details
    set title long_title font 'sans,30'
    set terminal png size 3200,1200
    set grid
    set xlabel "Date\nTime" font 'sans,18'
    #set xrange [ "2019-09-25" : "2019-09-26" ]
    #set xrange [ "2019-09-26 00:00" : "2019-09-27 06:00" ]
    set ylabel 'Bytes Transmitted' textcolor '#3CB371' font 'sans,18'
    set y2label 'Bytes Dropped' textcolor 'red' font 'sans,18'
    set ytics border nomirror textcolor '#3CB371'
    set y2tics border nomirror textcolor 'red'
    set autoscale y
    set autoscale y2

    # Time formatting
    set xdata time
    set timefmt "%Y-%m-%d\t%H:%M"
    set format x "%Y-%m-%d\n%H:%M"
    set mxtics 24
    set grid mxtics

    # Do the work
    plot data_file index 0 using 1:3 axis x1y1 with points pointtype 7 pointsize 1 linecolor rgb '#3CB371' title '', \
    '' using 1:4 axis x1y2 with points pointtype 7 pointsize 1 linecolor rgb 'red' title ''

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Karl Ratzsch@21:1/5 to All on Fri Sep 27 23:44:44 2019
    Am 27.09.2019 um 15:23 schrieb stuart.kendrick.sea@gmail.com:
    I would like to pull a single day out of my multi-week data file. So I'm using 'set xrange'. But I'm stumbling on the format: gnuplot fails with
    C:\Temp\Plot>gnuplot wst-a-rtr.gp
    "wst-a-rtr.gp" line 32: Can't plot with an empty x range!


    set xrange [ "2019-09-25" : "2019-09-26" ]


    Type "show xrange" after this, and you see it didnt work. "set
    xrange" does not understand formatted time data. Maybe it should
    give an error message here. E.g.

    print "2019-09-25" + 1

    gives

    2020.0

    gnuplots string autopromotion is perhaps a bit too ambitious here. ;)

    You need to transform those strings into a unix date, check the
    strptime() function.

    Karl

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Hans-Bernhard_Br=c3=b6ker@21:1/5 to All on Sat Sep 28 15:23:50 2019
    Am 27.09.2019 um 23:44 schrieb Karl Ratzsch:
    Am 27.09.2019 um 15:23 schrieb stuart.kendrick.sea@gmail.com:

    set xrange [ "2019-09-25" : "2019-09-26" ]

    Type "show xrange" after this, and you see it didnt work. "set
    xrange" does not understand formatted time data.

    That's not quite as true as you make it out to be. It can understand
    time/date strings, but you have to tell it to:

    gnuplot> set xdata time
    gnuplot> set timefmt '%Y-%m-%d'
    gnuplot> set xrange ['2019-02-07':'2020-03-31']
    gnuplot> show xrange

    set xdata time
    set xrange [ "2019-02-07" : "2020-03-31" ] noreverse nowriteback

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From stuart.kendrick.sea@gmail.com@21:1/5 to All on Mon Sep 30 04:19:29 2019
    I have fixed this

    My error was to place the 'set xrange' ahead of 'set timefmt'

    Fails:
    set xrange [ '2019-09-26 00:00' : '2019-09-27 06:00' ]
    set xdata time
    set timefmt "%Y-%m-%d\t%H:%M"

    Succeeds:
    set xdata time
    set timefmt "%Y-%m-%d\t%H:%M"
    set xrange [ '2019-09-26 00:00' : '2019-09-27 06:00' ]

    --sk

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)