绘制日期和时间间隔和持续时间

Plot date and time interval and duration

我有一个日期+时间开始和停止的列表,我想将其绘制为条形图。 X 轴应该从 00:00-23:59 开始,日期在 Y 轴上

我在gnuplot中尝试过绘图,但我的技能不够好。

数据格式如下:

Date Start Stop 06.03.2019 09:45 11:17 06.03.2019 14:40 15:20 07.03.2019 08:35 10:15 07.03.2019 14:05 14:45 08.03.2019 09:15 10:20 08.03.2019 13:55 14:45 09.03.2019 08:55 09:50 09.03.2019 13:15 14:36 10.03.2019 09:05 10:00

我想得到一个类似这样的图,但日期在 Y 轴上,所有条形图都在同一个图中。像这样:https://i.stack.imgur.com/A98t2.png.

非常感谢任何帮助。

以下内容可能是一个起点。条形图用 with boxxyerror 绘制。在此代码中,没有条目的天数不会显示为 y 轴上的标签。跨越午夜的间隔需要以不同方式处理。

代码:

### plot start stop times
reset session

$Data <<EOD
06.03.2019  09:45   11:17
06.03.2019  14:40   15:20
07.03.2019  08:35   10:15
07.03.2019  14:05   14:45
08.03.2019  09:15   10:20
08.03.2019  13:55   14:45
09.03.2019  08:55   09:50
09.03.2019  13:15   14:36
10.03.2019  09:05   10:00
12.03.2019  01:01   12:59
13.03.2019  00:00   23:59
EOD

$SpecialEvents <<EOD
08.03.2019  8:00
11.03.2019  4:00
13.03.2019  12:00
EOD

StartDay = "06.03.2019"
DaysAfterStartDay(day) = int((strptime("%d.%m.%Y",day)-strptime("%d.%m.%Y",StartDay))/86400)

set xdata time
set timefmt "%H:%M"
set format x "%H:%M"

plot $Data u (timecolumn(2)):(y=DaysAfterStartDay(strcol(1))): \
    (timecolumn(2)):(timecolumn(3)):(y-0.2):(y+0.2):ytic(1) w boxxyerror \
    fs solid 1.0 lc rgb "blue" notitle, \
    $SpecialEvents u (timecolumn(2)):(DaysAfterStartDay(strcol(1))):ytic(1) \
    with points pt 7 ps 2 lc rgb "red" notitle
### end of code

结果:

on-linecollection.

中有甘特图演示
#
# Very simple Gantt Chart
# Demonstrate using timecolumn(N,format) to plot time data from 
# multiple columns
#
$DATA << EOD
#Task start      end
A     2012-11-01 2012-12-31
B     2013-01-01 2013-03-14
C     2013-03-15 2014-04-30
D     2013-05-01 2013-06-30
E     2013-07-01 2013-08-31
F1    2013-09-01 2013-10-31
F2    2013-09-01 2014-01-17
F3    2013-09-01 2014-01-30
F4    2013-09-01 2014-03-31
G1    2013-11-01 2013-11-27
G2    2013-11-01 2014-01-17
L     2013-11-28 2013-12-19
M     2013-11-28 2014-01-17
N     2013-12-04 2014-03-02
O     2013-12-20 2014-01-17
P     2013-12-20 2014-02-16
Q     2014-01-05 2014-01-13
R     2014-01-18 2014-01-30
S     2014-01-31 2014-03-31
T     2014-03-01 2014-04-28
EOD

set xdata time
timeformat = "%Y-%m-%d"
set format x "%b\n'%y"

set yrange [-1:]
OneMonth = strptime("%m","2")
set xtics OneMonth nomirror
set xtics scale 2, 0.5
set mxtics 4
set ytics nomirror
set grid x y
unset key
set title "{/=15 Simple Gantt Chart}\n\n{/:Bold Task start and end times in columns 2 and 3}"
set border 3

T(N) = timecolumn(N,timeformat)

set style arrow 1 filled size screen 0.02, 15 fixed lt 3 lw 1.5

plot $DATA using (T(2)) : ([=10=]) : (T(3)-T(2)) : (0.0) : yticlabel(1) with vector as 1, \
     $DATA using (T(2)) : ([=10=]) : 1 with labels right offset -2