Python Gnuplot Read Csv File To Plot Time In X-axis In The Read Order Or Row Order
Solution 1:
(Edit: see at the bottom for the time-specific solution)
With this answer you'll need to work a bit on your specifics, but the solution is basically this.
I suggest that you use a counting system, storing in some variable whenever you increase by one day, which happens every time the value in column one is less than the previous value, e.g. 22:00:00 followed by 01:00:00. Consider the following data:
0 1
1 2
2 3
3 4
0 5
1 6
2 7
3 8
The cycle happens every 4 units (it would be 24 hours in your case). Plotted as is, this would look like this:
Now, with the following code you can keep track of "jumps" in the x value:
count=0
x0=1
plot "data" u ($1 < x0 ? (x0=$1, count=count+1, $1+4.*count) : \
(x0=$1, $1+4.*count) ):2 w l
The code above increases count
by one if the current x value is lower than the previous one. Then the x value is shifted to x + 4.*count
. Four is my cycle width (24 hours for you). This looks as below:
Time-specific solution:
Same principle, applied to OP's question:
set xdata time
set timefmt "%H:%M:%S"
set formatx"%d - %H:%M:%S"
set xtics 6*3600
count = 0x0 = 0
plot "data" u (timecolumn(1) < x0 ? (x0=timecolumn(1), count=count+1, \
$1+24*3600*count) : (x0=timecolumn(1), timecolumn(1)+24*3600*count) ):3 w l
Post a Comment for "Python Gnuplot Read Csv File To Plot Time In X-axis In The Read Order Or Row Order"