Дата, интервал времени и продолжительность - PullRequest
0 голосов
/ 30 апреля 2019

У меня есть список даты + времени начала и окончания, которые я хотел бы представить в виде баров. Ось 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.

Любая помощь очень ценится.

Ответы [ 2 ]

0 голосов
/ 30 апреля 2019

В онлайн-коллекции есть демонстрация диаграммы Ганта.

#
# 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)) : ($0) : (T(3)-T(2)) : (0.0) : yticlabel(1) with vector as 1, \
     $DATA using (T(2)) : ($0) : 1 with labels right offset -2

enter image description here

0 голосов
/ 30 апреля 2019

Следующее может быть отправной точкой. Бары нанесены с помощью 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

Результат:

enter image description here

...