re-add Ymin/Ymax calculation

re-add Ymin/Ymax calculation

#!/usr/bin/env gnuplot

# graph of CPU temperature

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql4gnuplot/sql11h.csv"
ifnamed = "/tmp/lnxdiagd/mysql4gnuplot/sql11d.csv"
ifnamew = "/tmp/lnxdiagd/mysql4gnuplot/sql11w.csv"
ifnamey = "/tmp/lnxdiagd/mysql4gnuplot/sql11y.csv"
set output "/tmp/lnxdiagd/site/img/day11.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,320
set style fill transparent solid 0.25 noborder
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94
TTPOS = 0.95
TBPOS = 0.55
BTPOS = 0.48
BBPOS = 0.08

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 1 name "X" nooutput

Xh_min = X_min + utc_offset - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnameh using 2 name "Yh" nooutput

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 1 name "X" nooutput

Xd_min = X_min + utc_offset - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnamed using 3 name "Yd" nooutput

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 1 name "X" nooutput
Xw_min = X_min + utc_offset - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

# stats for Y-axis
stats ifnamew using 4 name "Yw" nooutput

Ymax = max(max(Yd_max, Yh_max), Yw_max) +1
Ymin = min(min(Yd_min, Yh_min), Yw_min) -1

# ********************************************************* Statistics (Y) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamey using 1 name "X" nooutput
Xy_min = X_min + utc_offset - epoch_compensate
Xy_max = X_max + utc_offset - epoch_compensate

set multiplot layout 2, 3 title "CPU Temperature ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                  UPPER ROW
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set tmargin at screen TTPOS
set bmargin at screen TBPOS
set lmargin at screen LMARG
set rmargin at screen RMARG

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xy_min : Xy_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]"
set yrange [ : ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
set key reverse Left

# ***************************************************************** Output *****
# ***** PLOT *****
plot ifnamey \
      using ($1+utc_offset):2:4 with filledcurves lc rgb "#bb0000" \
  ,'' using ($1+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#bb0000"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                  LOWER ROW
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]"
set yrange [ Ymin : Ymax ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
set key reverse Left

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set tmargin at screen BTPOS
set bmargin at screen BBPOS
set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($1+utc_offset):2:4 notitle with filledcurves lc rgb "#bb0000" \
  ,'' using ($1+utc_offset):3 title " Temperature [degC]" with lines lw 0.1 fc rgb "#bb0000"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymin : Ymax ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($1+utc_offset):2:4 with filledcurves lc rgb "#bb0000" \
  ,'' using ($1+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#bb0000"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymin : Ymax ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):2 with points pt 5 ps 0.2 fc rgb "#bb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot

#!/usr/bin/env gnuplot

# graph of CPU temperature

# datafiles
ifnameh = "/tmp/lnxdiagd/mysql4gnuplot/sql11h.csv"
ifnamed = "/tmp/lnxdiagd/mysql4gnuplot/sql11d.csv"
ifnamew = "/tmp/lnxdiagd/mysql4gnuplot/sql11w.csv"
ifnamey = "/tmp/lnxdiagd/mysql4gnuplot/sql11y.csv"
set output "/tmp/lnxdiagd/site/img/day11.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 1280,320
set style fill transparent solid 0.25 noborder
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94
TTPOS = 0.95
TBPOS = 0.55
BTPOS = 0.48
BBPOS = 0.08

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 1 name "X" nooutput

Xh_min = X_min + utc_offset - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnameh using 2 name "Yh" nooutput

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 1 name "X" nooutput

Xd_min = X_min + utc_offset - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnamed using 3 name "Yd" nooutput

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 1 name "X" nooutput
Xw_min = X_min + utc_offset - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

# ********************************************************* Statistics (Y) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamey using 1 name "X" nooutput
Xy_min = X_min + utc_offset - epoch_compensate
Xy_max = X_max + utc_offset - epoch_compensate

set multiplot layout 2, 3 title "CPU Temperature ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                  UPPER ROW
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set tmargin at screen TTPOS
set bmargin at screen TBPOS
set lmargin at screen LMARG
set rmargin at screen RMARG

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xy_min : Xy_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]"
set yrange [ : ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
set key reverse Left

# ***************************************************************** Output *****
# ***** PLOT *****
plot ifnamey \
      using ($1+utc_offset):2:4 with filledcurves lc rgb "#bb0000" \
  ,'' using ($1+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#bb0000"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                  LOWER ROW
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Temperature [degC]"
set yrange [ Ymin : Ymax ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
set key reverse Left

# ***************************************************************** Output *****
# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

set tmargin at screen BTPOS
set bmargin at screen BBPOS
set lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($1+utc_offset):2:4 notitle with filledcurves lc rgb "#bb0000" \
  ,'' using ($1+utc_offset):3 title " Temperature [degC]" with lines lw 0.1 fc rgb "#bb0000"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymin : Ymax ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($1+utc_offset):2:4 with filledcurves lc rgb "#bb0000" \
  ,'' using ($1+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#bb0000"

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymin : Ymax ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen MRPOS+0.001
set rmargin at screen RMARG

# ***** PLOT *****
plot ifnameh \
      using ($1+utc_offset):2 with points pt 5 ps 0.2 fc rgb "#bb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot


show both graphs

show both graphs

#!/usr/bin/env gnuplot

# graph of current power usage and production
set output "/tmp/kamstrupd/kam_pastday.png"

# ******************************************************* General settings *****
set terminal png enhanced font "Vera,9" size 1280,640
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* Statistics     *****
# stats to be calculated here of column 1 (hour)
stats kamdata using 1 name "X" nooutput

Xh_min = X_min
Xh_max = X_max

set multiplot layout 2,1
set title "Verbruik recent ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                            PLOT: past hours
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "uur"             # X-axis label
#set xdata time               # Data on X-axis should be interpreted as time
#set timefmt "%s"             # Time in log-file is given in Unix format
#set format x "%a %d"            # Display time in 24 hour notation on the X axis
#set xrange [ Xh_min : Xh_max ]

# ***************************************************************** Y-axis *****
set ylabel "Verbruik [Wh]"
#set yrange [ 0 : Ymax ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
set key reverse Left

# ***************************************************************** Output *****
set style data histograms
set style histogram rowstacked
set boxwidth 1 relative
set style fill solid 1.0 noborder
set boxwidth 0.75

# set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder

#set lmargin at screen LMARG
#set rmargin at screen LMPOS

# ***** PLOT *****
plot kamdata using 2:xtic(1) title "T1", '' using 3 title "T2"
#plot ifnamew \
#      using ($1+utc_offset):4 title " Vermogen [W]" with lines lw 0.1 lc rgb "#ccbb0000"
#      # with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

set title "Productie recent ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)
set ylabel "Productie [Wh]"
set yrange [ 0 : 10 ]

plot kamdata using 4:xtic(1) title "T1", '' using 5 title "T2"


Some more changes to Makefile.gnu

Some more changes to Makefile.gnu

--HG--
branch : parser

# This is a plain Makefile for general Phorward Foundation Toolkit development.
# It should compile libphorward.a quickly and out of the box without autotools.

CFLAGS += -g -DDEBUG -DUNICODE -DUTF8 -I.

LIBPHORWARD = libphorward.a
PROTOFILE =	proto.h
LIBHEADER = phorward.h
PATHEXT = PATH="../run:$(PATH)"

SRC = \
	base/bitset.c \
	base/dbg.c \
	base/hashtab.c \
	base/llist.c \
	base/plist.c \
	base/memory.c \
	base/stack.c \
	ccl/ccl.c \
	regex/dfa.c \
	regex/direct.c \
	regex/misc.c \
	regex/nfa.c \
	regex/pattern.c \
	regex/pregex.c \
	regex/range.c \
	regex/ref.c \
	string/convert.c \
	string/string.c \
	string/utf8.c \
	util/base64.c \
	util/system.c \
	union/union.c \
	union/union.conv.c \
	union/union.get.c \
	union/union.set.c \
	xml/xml.c \
	\
	parser/error.c \
	parser/grammar.c \
	parser/nonterm.c \
	parser/lr.c \
	parser/parser.c \
	parser/production.c \
	parser/symbol.c \
	parser/terminal.c

HSRC = \
	base/bitset.h \
	base/dbg.h \
	base/hashtab.h \
	base/llist.h \
	base/plist.h \
	base/stack.h \
	ccl/ccl.h \
	phorward.tpl.h \
	regex/pregex.h \
	string/string.h \
	string/utf8.h \
	union/union.h \
	xml/xml.h \
	$(PROTOFILE)

OBJ = $(patsubst %.c,%.o,$(SRC))

all: $(LIBPHORWARD) ptest

ptest: ptest.o $(LIBPHORWARD)
	$(CC) -o $@ ptest.o $(LIBPHORWARD)

$(LIBPHORWARD): $(LIBHEADER) $(OBJ)
	ar rv $@ $(OBJ)

clean:
	-rm -f $(OBJ)
	-rm -f $(LIBPHORWARD)
	-rm -f ptest ptest.o

# Prototypes Files
$(PROTOFILE): $(SRC)
	$(PATHEXT) pproto $(SRC) >$@

# Library Header
$(LIBHEADER): $(HSRC)
	$(PATHEXT) pinclude phorward.tpl.h >$@

# Variant Data Type Modules (generated from definitions in var.h comments)
union/union.get.c: union/union.h union/union.gen.awk
	$(AWK) -f union/union.gen.awk -vwith_get=1 union/union.h >$@

union/union.set.c: union/union.h union/union.gen.awk
	$(AWK) -f union/union.gen.awk -vwith_set=1 union/union.h >$@

union/union.conv.c: union/union.h union/union.gen.awk
	$(AWK) -f union/union.gen.awk -vwith_conv=1 union/union.h >$@

# This is a plain Makefile for general Phorward Foundation Toolkit development.
# It should compile libphorward.a quickly and out of the box without autotools.

CFLAGS += -g -DDEBUG -DUNICODE -DUTF8 -I.

LIBPHORWARD = libphorward.a
PROTOFILE =	proto.h
LIBHEADER = phorward.h
PATHEXT = PATH="../run:$(PATH)"

SRC = \
	base/bitset.c \
	base/dbg.c \
	base/hashtab.c \
	base/llist.c \
	base/plist.c \
	base/memory.c \
	base/stack.c \
	ccl/ccl.c \
	regex/dfa.c \
	regex/direct.c \
	regex/misc.c \
	regex/nfa.c \
	regex/pattern.c \
	regex/pregex.c \
	regex/range.c \
	regex/ref.c \
	string/convert.c \
	string/string.c \
	string/utf8.c \
	util/base64.c \
	util/system.c \
	union/union.c \
	union/union.conv.c \
	union/union.get.c \
	union/union.set.c \
	xml/xml.c \
	\
	parser/error.c \
	parser/grammar.c \
	parser/nonterm.c \
	parser/lr.c \
	parser/parser.c \
	parser/production.c \
	parser/symbol.c \
	parser/terminal.c

HSRC = \
	base/bitset.h \
	base/dbg.h \
	base/hashtab.h \
	base/llist.h \
	base/plist.h \
	base/stack.h \
	ccl/ccl.h \
	phorward.tpl.h \
	regex/pregex.h \
	string/string.h \
	string/utf8.h \
	union/union.h \
	xml/xml.h \
	$(PROTOFILE)

OBJ = $(patsubst %.c,%.o,$(SRC))

$(LIBPHORWARD): $(LIBHEADER) $(OBJ)
	ar rv $@ $(OBJ)

clean:
	-rm -f $(OBJ)
	-rm -f $(LIBPHORWARD)

# Prototypes Files
$(PROTOFILE): $(SRC)
	$(PATHEXT) pproto $(SRC) >$@

# Library Header
$(LIBHEADER): $(HSRC)
	$(PATHEXT) pinclude phorward.tpl.h >$@

# Variant Data Type Modules (generated from definitions in var.h comments)
union/union.get.c: union/union.h union/union.gen.awk
	$(AWK) -f union/union.gen.awk -vwith_get=1 union/union.h >$@

union/union.set.c: union/union.h union/union.gen.awk
	$(AWK) -f union/union.gen.awk -vwith_set=1 union/union.h >$@

union/union.conv.c: union/union.h union/union.gen.awk
	$(AWK) -f union/union.gen.awk -vwith_conv=1 union/union.h >$@


add name -> number failure tests

add name -> number failure tests

:- begin_tests(numberals).
:- consult('numberals.pl').

logging :- fail.

log_writef(A, B) :- logging -> writef(A, B); true.
log_writef(A) :- log_writef(A, []).

test_both_ways(Num, Name) :-
	ground([Num, Name]),
	log_writef( '%q -> %s : ', [Num,  Name] ), number_to_name(Num, Test_Name), log_writef( 'Got %s', [Test_Name]), log_writef('\n'), Name = Test_Name,
	log_writef( '%s -> %q : ', [Name,  Num] ), number_to_name(Test_Num, Name), log_writef( 'Got %q', [Test_Num ]), log_writef('\n'), log_writef('\n'), Num  = Test_Num.

test_name_fail(Name) :-
	log_writef( 'Testing name %s : ', [Name]),
	(\+ number_to_name(_, Name) -> log_writef('not found - ok'), log_writef('\n');
		log_writef('found - fail'), log_writef('\n'), fail), log_writef('\n').
test_num_fail(Num) :-
	log_writef( 'Testing number %q : ', [Num]),
	(\+ number_to_name(Num, _) -> log_writef('not found - ok'), log_writef('\n');
		log_writef('found - fail'), log_writef('\n'), fail), log_writef('\n').

test_both_ways_test([0], "zero").
test_both_ways_test(['-',0], "negative zero"). % signed zero

test_both_ways_test([1,0], "ten").
test_both_ways_test([-,1,0], "negative ten").
test_both_ways_test([1,4], "fourteen").
test_both_ways_test([-,1,4], "negative fourteen").

test_both_ways_test([2,0], "twenty").
test_both_ways_test([-,2,0], "negative twenty").
test_both_ways_test([2,1], "twenty-one").
test_both_ways_test([-,2,1], "negative twenty-one").

test_both_ways_test([3,2], "thirty-two").
test_both_ways_test([-,3,2], "negative thirty-two").
test_both_ways_test([3,5], "thirty-five").
test_both_ways_test([-,3,5], "negative thirty-five").

test_both_ways_test([1, 3,5], "one hundred and thirty-five").
test_both_ways_test([-,1, 3,5], "negative one hundred and thirty-five").
test_both_ways_test([1,0,0], "one hundred").
test_both_ways_test([-,1,0,0], "negative one hundred").
test_both_ways_test([2,0,0], "two hundred").
test_both_ways_test([-,2,0,0], "negative two hundred").
test_both_ways_test([2,0,1], "two hundred and one").
test_both_ways_test([-,2,0,1], "negative two hundred and one").
test_both_ways_test([2,2,0], "two hundred and twenty").
test_both_ways_test([-,2,2,0], "negative two hundred and twenty").
test_both_ways_test([2,2,5], "two hundred and twenty-five").
test_both_ways_test([-,2,2,5], "negative two hundred and twenty-five").
test_both_ways_test([3,1,0], "three hundred and ten").
test_both_ways_test([-,3,1,0], "negative three hundred and ten").
test_both_ways_test([9,9,9], "nine hundred and ninety-nine").
test_both_ways_test([-,9,9,9], "negative nine hundred and ninety-nine").

test_both_ways_test([1,0,0,0], "one thousand").
test_both_ways_test([-,1,0,0,0], "negative one thousand").
test_both_ways_test([1,0,0,2], "one thousand two").
test_both_ways_test([-,1,0,0,2], "negative one thousand two").
test_both_ways_test([1,0,2,2], "one thousand twenty-two").
test_both_ways_test([-,1,0,2,2], "negative one thousand twenty-two").
test_both_ways_test([1,9,9,9], "one thousand nine hundred and ninety-nine").
test_both_ways_test([-,1,9,9,9], "negative one thousand nine hundred and ninety-nine").
test_both_ways_test([1,0,9,9,9], "ten thousand nine hundred and ninety-nine").
test_both_ways_test([-,1,0,9,9,9], "negative ten thousand nine hundred and ninety-nine").
test_both_ways_test([1,0,0,0,0,0,0], "one million").
test_both_ways_test([-,1,0,0,0,0,0,0], "negative one million").
test_both_ways_test([2,0,0,0,0,0,0], "two million").
test_both_ways_test([-,2,0,0,0,0,0,0], "negative two million").
test_both_ways_test([2,0,0,0,9,0,0], "two million nine hundred").
test_both_ways_test([2,0,0,0,0,9,0], "two million ninety").
test_both_ways_test([2,0,0,0,0,0,9], "two million nine").
test_both_ways_test([1,0,2,0,0,0,0,0,0], "one hundred and two million").
test_both_ways_test([-,1,0,2,0,0,0,0,0,0], "negative one hundred and two million").
test_both_ways_test([1,0,2,0,0,0,0,0,9], "one hundred and two million nine").
test_both_ways_test([2,0,0,1,0,0,0,1,0,9], "two billion one million one hundred and nine").
test_both_ways_test([2,0,0,1,1,0,0,1,0,9], "two billion one million one hundred thousand one hundred and nine").
test_both_ways_test([2,0,0,1,1,2,0,1,0,9], "two billion one million one hundred and twenty thousand one hundred and nine").
test_both_ways_test([2,0,0,1,1,2,3,1,0,9], "two billion one million one hundred and twenty-three thousand one hundred and nine").
test_both_ways_test([2,0,0,0,0,0,1,0,0,0,1,0,9], "two trillion one million one hundred and nine").

test(test_both_ways, [nondet, forall( test_both_ways_test(Num, Name))]) :-
	test_both_ways(Num, Name).

%test(test_both_ways, [nondet, forall( test_both_ways_test_f(Num, Name))]) :-
	%\+ test_both_ways(Num, Name).

%test(test_to_name, [nondet, forall( test_to_name_test(Num, Name) )]) :-
	%%number_to_name(Num, Test_Name), Test_Name = Name.
	%number_to_name(Num, Test_Name), ( Test_Name = Name -> true; write(Test_Name), nl, writef('%s', [Test_Name]), nl, fail).

test_name_fail_test("zero hundred").
test_name_fail_test("zero thousand").
test_name_fail_test("zero million").
test_name_fail_test("one million "). % extra space
test_name_fail_test("zero million zero thousand").
test_name_fail_test("zero million zero thousand zero").
test_name_fail_test("zero million one thousand").
test_name_fail_test("one million zero thousand zero").
test_name_fail_test("one million zero thousand one").
test(test_name_fail, [nondet, forall( test_name_fail_test(Name) )]) :-
	test_name_fail(Name).

test_num_fail_test([1,-,0]).
test_num_fail_test([-,-,0]).
test_num_fail_test([-,-,-]).
test_num_fail_test([0,0,0]).
test_num_fail_test([0,0,0,0]).
test_num_fail_test([-,-,-,-]).
test(test_num_fail, [nondet, forall( test_num_fail_test(Num) )]) :-
	test_num_fail(Num).

:- end_tests(numberals).

% vim:ft=prolog:fdm=marker

:- begin_tests(numberals).
:- consult('numberals.pl').

logging :- fail.

log_writef(A, B) :- logging -> writef(A, B); true.
log_writef(A) :- log_writef(A, []).

test_both_ways(Num, Name) :-
	ground([Num, Name]),
	log_writef( '%q -> %s : ', [Num,  Name] ), number_to_name(Num, Test_Name), log_writef( 'Got %s', [Test_Name]), log_writef('\n'), Name = Test_Name,
	log_writef( '%s -> %q : ', [Name,  Num] ), number_to_name(Test_Num, Name), log_writef( 'Got %q', [Test_Num ]), log_writef('\n'), log_writef('\n'), Num  = Test_Num.

test_name_fail(Name) :-
	log_writef( 'Testing name %s : ', [Name]),
	(\+ number_to_name(_, Name) -> log_writef('not found - ok'), log_writef('\n');
		log_writef('found - fail'), log_writef('\n'), fail), log_writef('\n').
test_num_fail(Num) :-
	log_writef( 'Testing number %q : ', [Num]),
	(\+ number_to_name(Num, _) -> log_writef('not found - ok'), log_writef('\n');
		log_writef('found - fail'), log_writef('\n'), fail), log_writef('\n').

test_both_ways_test([0], "zero").
test_both_ways_test(['-',0], "negative zero"). % signed zero

test_both_ways_test([1,0], "ten").
test_both_ways_test([-,1,0], "negative ten").
test_both_ways_test([1,4], "fourteen").
test_both_ways_test([-,1,4], "negative fourteen").

test_both_ways_test([2,0], "twenty").
test_both_ways_test([-,2,0], "negative twenty").
test_both_ways_test([2,1], "twenty-one").
test_both_ways_test([-,2,1], "negative twenty-one").

test_both_ways_test([3,2], "thirty-two").
test_both_ways_test([-,3,2], "negative thirty-two").
test_both_ways_test([3,5], "thirty-five").
test_both_ways_test([-,3,5], "negative thirty-five").

test_both_ways_test([1, 3,5], "one hundred and thirty-five").
test_both_ways_test([-,1, 3,5], "negative one hundred and thirty-five").
test_both_ways_test([1,0,0], "one hundred").
test_both_ways_test([-,1,0,0], "negative one hundred").
test_both_ways_test([2,0,0], "two hundred").
test_both_ways_test([-,2,0,0], "negative two hundred").
test_both_ways_test([2,0,1], "two hundred and one").
test_both_ways_test([-,2,0,1], "negative two hundred and one").
test_both_ways_test([2,2,0], "two hundred and twenty").
test_both_ways_test([-,2,2,0], "negative two hundred and twenty").
test_both_ways_test([2,2,5], "two hundred and twenty-five").
test_both_ways_test([-,2,2,5], "negative two hundred and twenty-five").
test_both_ways_test([3,1,0], "three hundred and ten").
test_both_ways_test([-,3,1,0], "negative three hundred and ten").
test_both_ways_test([9,9,9], "nine hundred and ninety-nine").
test_both_ways_test([-,9,9,9], "negative nine hundred and ninety-nine").

test_both_ways_test([1,0,0,0], "one thousand").
test_both_ways_test([-,1,0,0,0], "negative one thousand").
test_both_ways_test([1,0,0,2], "one thousand two").
test_both_ways_test([-,1,0,0,2], "negative one thousand two").
test_both_ways_test([1,0,2,2], "one thousand twenty-two").
test_both_ways_test([-,1,0,2,2], "negative one thousand twenty-two").
test_both_ways_test([1,9,9,9], "one thousand nine hundred and ninety-nine").
test_both_ways_test([-,1,9,9,9], "negative one thousand nine hundred and ninety-nine").
test_both_ways_test([1,0,9,9,9], "ten thousand nine hundred and ninety-nine").
test_both_ways_test([-,1,0,9,9,9], "negative ten thousand nine hundred and ninety-nine").
test_both_ways_test([1,0,0,0,0,0,0], "one million").
test_both_ways_test([-,1,0,0,0,0,0,0], "negative one million").
test_both_ways_test([2,0,0,0,0,0,0], "two million").
test_both_ways_test([-,2,0,0,0,0,0,0], "negative two million").
test_both_ways_test([2,0,0,0,9,0,0], "two million nine hundred").
test_both_ways_test([2,0,0,0,0,9,0], "two million ninety").
test_both_ways_test([2,0,0,0,0,0,9], "two million nine").
test_both_ways_test([1,0,2,0,0,0,0,0,0], "one hundred and two million").
test_both_ways_test([-,1,0,2,0,0,0,0,0,0], "negative one hundred and two million").
test_both_ways_test([1,0,2,0,0,0,0,0,9], "one hundred and two million nine").
test_both_ways_test([2,0,0,1,0,0,0,1,0,9], "two billion one million one hundred and nine").
test_both_ways_test([2,0,0,1,1,0,0,1,0,9], "two billion one million one hundred thousand one hundred and nine").
test_both_ways_test([2,0,0,1,1,2,0,1,0,9], "two billion one million one hundred and twenty thousand one hundred and nine").
test_both_ways_test([2,0,0,1,1,2,3,1,0,9], "two billion one million one hundred and twenty-three thousand one hundred and nine").
test_both_ways_test([2,0,0,0,0,0,1,0,0,0,1,0,9], "two trillion one million one hundred and nine").

test(test_both_ways, [nondet, forall( test_both_ways_test(Num, Name))]) :-
	test_both_ways(Num, Name).

%test(test_both_ways, [nondet, forall( test_both_ways_test_f(Num, Name))]) :-
	%\+ test_both_ways(Num, Name).

%test(test_to_name, [nondet, forall( test_to_name_test(Num, Name) )]) :-
	%%number_to_name(Num, Test_Name), Test_Name = Name.
	%number_to_name(Num, Test_Name), ( Test_Name = Name -> true; write(Test_Name), nl, writef('%s', [Test_Name]), nl, fail).

test_name_fail_test("zero hundred").
test(test_name_fail, [nondet, forall( test_name_fail_test(Name) )]) :-
	test_name_fail(Name).

test_num_fail_test([1,-,0]).
test_num_fail_test([-,-,0]).
test_num_fail_test([-,-,-]).
test_num_fail_test([0,0,0]).
test_num_fail_test([0,0,0,0]).
test_num_fail_test([-,-,-,-]).
test(test_num_fail, [nondet, forall( test_num_fail_test(Num) )]) :-
	test_num_fail(Num).

:- end_tests(numberals).

% vim:ft=prolog:fdm=marker


Tweaked graph style again

Tweaked graph style again

#Expects data to be in data.csv
# Unfortunately, we can't read from the pipe becuase we need to read from the file twice :-(
set datafile separator ","

set logscale y

set title "Puzzle provided difficulty vs markov difficulty"
set xlabel "Puzzle index (sorted by markov difficulty)"
set ylabel "Markov Difficulty (log scale)"
set y2label "Provided Difficulty"

set ytics scale 0.01
set y2tics scale 1.0

#0 is a special column that starts from 0 and increments by 1 for each row.
plot 'data.csv' using 0:3title "Markov Difficulties" with lines, \
'data.csv' using 0:2 title "Official Difficulties" axes x1y2 with lines

#Expects data to be in data.csv
# Unfortunately, we can't read from the pipe becuase we need to read from the file twice :-(
set datafile separator ","

set logscale y

set title "Puzzle provided difficulty vs markov difficulty"
set xlabel "Puzzles sorted by Markov Difficulty"
set ylabel "Markov Difficulty (log scale)"
set y2label "Provided Difficulty"

set ytics scale 0.01
set y2tics scale 1.0

#0 is a special column that starts from 0 and increments by 1 for each row.
plot 'data.csv' using 0:3title "Markov Difficulties" with lines, \
'data.csv' using 0:2 title "Official Difficulties" axes x1y2 with lines


Wait for 5 seconds after plotting

Wait for 5 seconds after plotting

set xdata time
set timefmt "%Y-%m-%d"
set format x "%Y-%m-%d"
plot "commits_all_projs.dat" using 1:2 with steps
pause 5


Plot performance overview (assuming a moderate sized set of cases); the SMM code sample may be used to investigate single-thread performance and scalability tests.

MPARM = 1
NPARM = 2
KPARM = 3
FLOPS = 7

HIM = -1
HIN = HIM
HIK = HIM
MN = 23
PEAK = 0 #985.6

BASENAME = "smm"
FILENAME = system("sh -c \"echo ${FILENAME}\"")
if (FILENAME eq "") {
  FILENAME = BASENAME."-perf.pdf"
}

FILECOUNT = 1 # initial file number
# MULTI =-1: multiple files; no titles
# MULTI = 0: multiple files with titles
# MULTI = 1: single file with titles
MULTI = system("sh -c \"echo ${MULTI}\"")
if (MULTI eq "") {
  MULTI = 1
}

if (MULTI==1) {
  set output FILENAME
}

FILEEXT = system("sh -c \"echo ".FILENAME." | sed 's/.\\+\\.\\(.\\+\\)/\\1/'\"")
set terminal FILEEXT
set termoption enhanced
#set termoption font ",12"
save_encoding = GPVAL_ENCODING
set encoding utf8

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance" }
set style fill solid 0.4 border -1
set style data histograms
set style histogram cluster #gap 2
#set boxwidth 0.5 relative
set grid y2tics lc "grey"
set key left #spacing 0.5
set xtics rotate by -45 scale 0; set bmargin 6
set ytics format ""
set y2tics nomirror
set y2label "GFLOP/s"
set yrange [0:*]
plot  BASENAME."-inlined.dat" using FLOPS title "Inlined", \
      BASENAME."-blas.dat" using FLOPS title "BLAS", \
      BASENAME."-dispatched.dat" using FLOPS title "Dispatched", \
      BASENAME."-specialized.dat" using FLOPS:xtic("(".strcol(MPARM).",".strcol(NPARM).",".strcol(KPARM).")") title "Specialized"

MPARM = 1
NPARM = 2
KPARM = 3
FLOPS = 7

HIM = -1
HIN = HIM
HIK = HIM
MN = 23
PEAK = 0 #985.6

BASENAME = "smm"
FILENAME = system("sh -c \"echo ${FILENAME}\"")
if (FILENAME eq "") {
  FILENAME = BASENAME."-perf.pdf"
}

FILECOUNT = 1 # initial file number
# MULTI =-1: multiple files; no titles
# MULTI = 0: multiple files with titles
# MULTI = 1: single file with titles
MULTI = system("sh -c \"echo ${MULTI}\"")
if (MULTI eq "") {
  MULTI = 1
}

NFLOPS(M, N, K) = 2 * column(M) * column(N) * column(K)
NBYTES(M, N, K, ELEMSIZE) = ELEMSIZE * (column(M) * column(K) + column(K) * column(N) + column(M) * column(N))
AI(M, N, K, ELEMSIZE) = NFLOPS(M, N, K) / NBYTES(M, N, K, ELEMSIZE)

stats BASENAME.".dat" using (NFLOPS(MPARM,NPARM,KPARM)) nooutput; MNK = STATS_stddev**(1.0/3.0); MAXMNK = int(STATS_max)
stats BASENAME."-specialized.dat" using (log(column(FLOPS))) nooutput; GEO = exp(STATS_sum/STATS_records)
stats BASENAME."-specialized.dat" using FLOPS nooutput; MED = STATS_median; MINFLOPS = STATS_min; MAXFLOPS = STATS_max
stats BASENAME."-specialized.dat" using NPARM nooutput; XN = int(STATS_max)

MAX(A, B) = A < B ? B : A
ACC = sprintf("%%.%if", ceil(MAX(1.0 / log10(MED) - 1.0, 0)))

IX(I1, J1, NJ) = int(MAX(I1 - 1, 0) * NJ + MAX(J1 - 1, 0))
I1(IX, NJ) = int(IX / NJ) + 1
J1(IX, NJ) = int(IX) % NJ + 1

set table BASENAME."-avg.dat"
plot BASENAME."-specialized.dat" using (IX(column(MPARM), column(NPARM), XN)):FLOPS smooth unique
unset table
set table BASENAME."-cdf.dat"
plot BASENAME."-specialized.dat" using FLOPS:(1.0) smooth cumulative
unset table
stats BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?($2):(1/0)) nooutput; FREQSUM = STATS_max; FREQN = STATS_records

if (MULTI==1) {
  set output FILENAME
}

FILEEXT = system("sh -c \"echo ".FILENAME." | sed 's/.\\+\\.\\(.\\+\\)/\\1/'\"")
set terminal FILEEXT
set termoption enhanced
#set termoption font ",12"
save_encoding = GPVAL_ENCODING
set encoding utf8

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance" }
set style fill solid 0.4 border -1
set style data histograms
set style histogram cluster #gap 2
#set boxwidth 0.5 relative
set grid y2tics lc "grey"
set key left #spacing 0.5
set xtics rotate by -45 scale 0; set bmargin 6
set ytics format ""
set y2tics nomirror
set y2label "GFLOP/s"
set yrange [0:*]
plot  BASENAME."-inlined.dat" using FLOPS title "Inlined", \
      BASENAME."-blas.dat" using FLOPS title "BLAS", \
      BASENAME."-dispatched.dat" using FLOPS title "Dispatched", \
      BASENAME."-specialized.dat" using FLOPS:xtic("(".strcol(MPARM).",".strcol(NPARM).",".strcol(KPARM).")") title "Specialized"

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance (K-Average)" }
set origin -0.02, 0
set dgrid3d #9, 9
set pm3d interpolate 0, 0 map
set autoscale fix
set xlabel "M"
set ylabel "N" offset -1.5
set cblabel "GFLOP/s" offset 0.5
set format x "%g"; set format y "%g"; set format cb "%g"
set mxtics 2
splot BASENAME."-avg.dat" using (("".strcol(3)."" eq "i")?(I1($1, XN)):(1/0)):(("".strcol(3)."" eq "i")?(J1($1, XN)):(1/0)):2 notitle with pm3d

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance (Average per Bin of Problem Size)" }
set style fill solid 0.4 border -1
set boxwidth 0.5
set grid y2tics lc "grey"
unset key
unset xtics
set x2tics ("Small" 0, "Medium" 1, "Larger" 2) scale 0
set xrange [-0.5:2.5]
set ytics format ""
set y2tics nomirror
set y2label "GFLOP/s"
plot  BASENAME."-specialized.dat" \
      using (0.0):((((0.0)<NFLOPS(MPARM,NPARM,KPARM))&&(NFLOPS(MPARM,NPARM,KPARM)<=(13*13*13)))?column(FLOPS):1/0) notitle smooth unique with boxes, \
  ""  using (1.0):((((13*13*13)<NFLOPS(MPARM,NPARM,KPARM))&&(NFLOPS(MPARM,NPARM,KPARM)<=(23*23*23)))?column(FLOPS):1/0) notitle smooth unique with boxes, \
  ""  using (2.0):((((23*23*23)<NFLOPS(MPARM,NPARM,KPARM))&&(NFLOPS(MPARM,NPARM,KPARM)<=(MAXMNK)))?column(FLOPS):1/0) notitle smooth unique with boxes

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) {
  set title "Performance (CDF)"
  set xlabel "Probability\n\nMin.: ".sprintf(ACC, MINFLOPS)." GFLOP/s  Geo. Mean: ".sprintf(ACC, GEO)." GFLOP/s  Median: ".sprintf(ACC, MED)." GFLOP/s  Max.: ".sprintf(ACC, MAXFLOPS)." GFLOP/s"
} else {
  set xlabel "Probability"
}
set y2label "GFLOP/s"
set y2tics nomirror
unset ytics
set format x "%g%%"
set format y "%g"
set fit quiet
f(x) = b * x + a
fit f(x) BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 via a, b
g(x) = (x - a) / b
x50 = 0.5 * (100 + MAX(0, g(0)))
h(x) = d * x + c
dx = 100 / FREQN
fit [x50-1.5*dx:x50+1.5*dx] h(x) BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 via c, d
set arrow 1 from x50, h(x50) to x50, 0
set label 1 sprintf("%.0f%%", x50) at x50, 0.5 * h(x50) left offset 1
set arrow 2 from x50, h(x50) to 100, h(x50)
set label 2 sprintf(ACC." GFLOP/s", h(x50)) at 0.5 * (x50 + 100.0), h(x50) centre offset 0, -1
set autoscale fix
set xrange [0:100]
set yrange [0:*]
plot BASENAME."-cdf.dat" using (("".strcol(3)."" eq "i")?(100*$2/FREQSUM):(1/0)):1 notitle with lines

reset
if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
if (MULTI>-1) { set title "Performance and Arithmetic Intensity" }
set grid y2tics lc "grey"
set key left #spacing 0.5
set ytics format ""
set y2tics nomirror
set y2label "GFLOP/s"
set xlabel "FLOPS/Byte"
plot  BASENAME."-specialized.dat" using (AI(MPARM,NPARM,KPARM,8)):FLOPS notitle smooth sbezier with lines linecolor "grey", \
                               "" using (AI(MPARM,NPARM,KPARM,8)):FLOPS notitle smooth unique with points pointtype 7 pointsize 0.1

if (0 < PEAK) {
  reset
  if (MULTI<=0) { set output "".FILECOUNT."-".FILENAME; FILECOUNT = FILECOUNT + 1 }
  if (MULTI>-1) { set title "Performance and Efficiency" }
  set xlabel "(M N K)^{-1/3}"
  set ylabel "Efficiency"
  set y2label "GFLOP/s"
  set y2tics
  set ytics nomirror
  set format x "%g"; set format y "%g%%"
  set mxtics 2
  set mytics 2
  set my2tics 2
  set autoscale fix
  set yrange [0:100]
  set y2range [0:PEAK]
  plot BASENAME."-specialized.dat" using (floor(NFLOPS(MPARM,NPARM,KPARM)**(1.0/3.0)+0.5)):(100.0*column(FLOPS)/PEAK) notitle smooth sbezier with points pointtype 7 pointsize 0.5
}


Tweaked cavity.plt.

Tweaked cavity.plt.

# Script to plot the cavity multipole field maps.
#
# Author: Johan Bengtsson.

home_dir = '/home/bengtsson/FRIB/Cavity Model/';

# Terminal type is: 0 - X11, 1 - PS, 2 - PNG, 3 - JPG
term_type = 0;

# On-axis long. E-field [V/m] vs. z [mm].
file1 = home_dir."axisData_41.txt";

# Transverse higher order E-field [V/m] ([V] for dipole) vs. z [mm].
# Dipole.
file2 = home_dir."Multipole41/CaviMlp_EDipole_41.txt";
# First half of defocusing component.
file3 = home_dir."Multipole41/CaviMlp_EFocus1_41.txt";
# Second half of defocusing component.
file4 = home_dir."Multipole41/CaviMlp_EFocus2_41.txt";
# Quadrupole.
file5 = home_dir."Multipole41/CaviMlp_EQuad_41.txt";

# Tranverse higher order H-field [A/m] ([A] for dipole) vs. z [mm]
file6 = home_dir."Multipole41/CaviMlp_HDipole_41.txt";
file7 = home_dir."Multipole41/CaviMlp_HMono_41.txt";
file8 = home_dir."Multipole41/CaviMlp_HQuad_41.txt";
file9 = home_dir."Multipole41/thinlenlon_41.txt";

if (term_type == 0) set terminal x11;
if (term_type == 1) set terminal postscript landscape enhanced color solid \
  lw 2 "Times-Roman" 15;
#if (term_type == 2) set terminal pngcairo size 350, 262 enhanced \
#  font 'Verdana,10';
if (term_type == 2) set terminal pngcairo enhanced font "Times-Roman";
if (term_type == 3) set terminal jpeg enhanced;

set grid;

set style line 1 lt 1 lw 1 lc rgb "blue";
set style line 2 lt 1 lw 1 lc rgb "cyan";
set style line 3 lt 1 lw 1 lc rgb "green";
set style line 4 lt 1 lw 1 lc rgb "red";
set style line 5 lt 1 lw 1 lc rgb "dark-green";
set style line 6 lt 1 lw 1 lc rgb "dark-orange";
set style line 7 lt 1 lw 1 lc rgb "dark-violet";
set style line 8 lt 1 lw 1 lc rgb "orange-red";

if (term_type == 1) set output "cavity_1.ps"
if (term_type == 2) set output "cavity_1.png"
if (term_type == 3) set output "cavity_1.jpg"

set title "Cavity Fundamental Mode: axisData";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \174\174} [MV/m]";
plot file1 using (1e-1*$1):(1e-6*$2) notitle with lines ls 1;

if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_2.ps"
if (term_type == 2) set output "cavity_2.png"
if (term_type == 3) set output "cavity_2.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: EDipole";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \\136} [MV]";
plot file2 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity Mode: EQuad";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \\136} [MV/m]";
plot file5 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity: EFocus1";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \\136} [MV/m]";
plot file3 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.5, 0.0;
set title "Cavity: EFocus2";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \\136} [MV/m]";
plot file4 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_3.ps"
if (term_type == 2) set output "cavity_3.png"
if (term_type == 3) set output "cavity_3.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: HDipole";
set xlabel "z [cm]"; set ylabel "H_{/Symbol \\136} [kA]";
plot file6 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity Mode: HMono";
set xlabel "z [cm]"; set ylabel "H_{/Symbol \\136} [kA/m]";
plot file7 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity Mode: HQuad";
set xlabel "z [cm]"; set ylabel "H_{/Symbol \\136} [kA/m]";
plot file8 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_4.ps"
if (term_type == 2) set output "cavity_4.png"
if (term_type == 3) set output "cavity_4.jpg"

set size 1.0, 1.0; set origin 0.0, 0.0;
set title "Cavity Thin Lens Model: {/Symbol \\362}Eds,  {/Symbol \\362}Hds";
set xlabel "z [cm]";
set ylabel "[MV, MV/m, MA, MA/m]";
set yrange [-0.01:];
plot file9 using (1e-1*($1+$4/2.0)):6:(1e-1*$4) notitle with boxes ls 3;
if (term_type == 0) pause mouse "click on graph to cont.\n";

# Script to plot the cavity multipole field maps.
#
# Author: Johan Bengtsson.

home_dir = '/home/bengtsson/FRIB/Cavity Model/';

# Terminal type is: 0 - X11, 1 - PS, 2 - PNG, 3 - JPG
term_type = 0;

# On-axis long. E-field [V/m] vs. z [mm].
file1 = home_dir."axisData_41.txt";

# Transverse higher order E-field [V/m] ([V] for dipole) vs. z [mm].
# Dipole.
file2 = home_dir."Multipole41/CaviMlp_EDipole_41.txt";
# First half of defocusing component.
file3 = home_dir."Multipole41/CaviMlp_EFocus1_41.txt";
# Second half of defocusing component.
file4 = home_dir."Multipole41/CaviMlp_EFocus2_41.txt";
# Quadrupole.
file5 = home_dir."Multipole41/CaviMlp_EQuad_41.txt";

# Tranverse higher order H-field [A/m] ([A] for dipole) vs. z [mm]
file6 = home_dir."Multipole41/CaviMlp_HDipole_41.txt";
file7 = home_dir."Multipole41/CaviMlp_HMono_41.txt";
file8 = home_dir."Multipole41/CaviMlp_HQuad_41.txt";
file9 = home_dir."Multipole41/thinlenlon_41.txt";

if (term_type == 0) set terminal x11;
if (term_type == 1) set terminal postscript landscape enhanced color solid \
  lw 2 "Times-Roman" 15;
#if (term_type == 2) set terminal pngcairo size 350, 262 enhanced \
#  font 'Verdana,10';
if (term_type == 2) set terminal pngcairo enhanced font "Times-Roman";
if (term_type == 3) set terminal jpeg enhanced;

set grid;

set style line 1 lt 1 lw 1 lc rgb "blue";
set style line 2 lt 1 lw 1 lc rgb "cyan";
set style line 3 lt 1 lw 1 lc rgb "green";
set style line 4 lt 1 lw 1 lc rgb "red";
set style line 5 lt 1 lw 1 lc rgb "dark-green";
set style line 6 lt 1 lw 1 lc rgb "dark-orange";
set style line 7 lt 1 lw 1 lc rgb "dark-violet";
set style line 8 lt 1 lw 1 lc rgb "orange-red";

if (term_type == 1) set output "cavity_1.ps"
if (term_type == 2) set output "cavity_1.png"
if (term_type == 3) set output "cavity_1.jpg"

set title "Cavity Fundamental Mode: axisData";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \174\174} [MV/m]";
plot file1 using (1e-1*$1):(1e-6*$2) notitle with lines ls 1;

if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_2.ps"
if (term_type == 2) set output "cavity_2.png"
if (term_type == 3) set output "cavity_2.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: EDipole";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \\136} [MV]";
plot file2 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity Mode: EQuad";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \\136} [MV/m]";
plot file5 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity: EFocus1 & EFocus2";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \\136} [MV/m]";
plot file3 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3, \
     file4 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_3.ps"
if (term_type == 2) set output "cavity_3.png"
if (term_type == 3) set output "cavity_3.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: HDipole";
set xlabel "z [cm]"; set ylabel "H_{/Symbol \\136} [kA]";
plot file6 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity Mode: HMono";
set xlabel "z [cm]"; set ylabel "H_{/Symbol \\136} [kA/m]";
plot file7 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity Mode: HQuad";
set xlabel "z [cm]"; set ylabel "H_{/Symbol \\136} [kA/m]";
plot file8 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_4.ps"
if (term_type == 2) set output "cavity_4.png"
if (term_type == 3) set output "cavity_4.jpg"

set size 1.0, 1.0; set origin 0.0, 0.0;
set title "Cavity Thin Lens Model: {/Symbol \\362}Eds,  {/Symbol \\362}Hds";
set xlabel "z [cm]";
set ylabel "[MV, MV/m, MA, MA/m]";
set yrange [-0.01:];
plot file9 using (1e-1*($1+$4/2.0)):6:(1e-1*$4) notitle with boxes ls 3;
if (term_type == 0) pause mouse "click on graph to cont.\n";


stats

stats

set terminal pdf color
set xdata time
set timefmt "%d/%m/%y"
set format x "%d/%m"
set output "stats.pdf"
set y2tics
FACTOR=0.003
#set xrange ["20/05/14":"30/12/14"]
#set yrange [17:120]
#set grid
set xlabel 'Date'
set ylabel 'Nombre'
set key on left box
plot "plot.dat" using 1:2 with lines ti "Pages", "plot.dat" using 1:3 with lines ti "Todo", "plot.dat" using 1:(FACTOR*$4) with lines ti "Mots"

set terminal pdf color
set xdata time
set timefmt "%d/%m/%y"
set output "stats.pdf"
set y2tics
FACTOR=0.003
#set xrange ["20/05/14":"30/12/14"]
#set yrange [17:120]
#set grid
set xlabel 'Date'
set ylabel 'Nombre'
set key on left box
plot "plot.dat" using 1:2 with lines ti "Pages", "plot.dat" using 1:3 with lines ti "Todo", "plot.dat" using 1:(FACTOR*$4) with lines ti "Mots"


Change key location.

Change key location.

# Note you need gnuplot 4.4 for the pdfcairo terminal.

# set terminal pdfcairo font "Gill Sans,9" linewidth 4 rounded fontscale 1.0
set terminal pdfcairo font "Gill Sans,7" linewidth 1 rounded fontscale 1.0

# Line style for axes
set style line 80 lt rgb "#808080"

# Line style for grid
set style line 81 lt 0  # dashed
set style line 81 lt rgb "#808080"  # grey

set grid back linestyle 81
set border 3 back linestyle 80 # Remove border on top and right.  These
             # borders are useless and make it harder
             # to see plotted lines near the border.
    # Also, put it in grey; no need for so much emphasis on a border.
# set xtics nomirror
# set ytics nomirror

#set log y
#set mxtics 10    # Makes logscale look good.

# Line styles: try to pick pleasing colors, rather
# than strictly primary colors or hard-to-see colors

# like gnuplot's default yellow.  Make the lines thick
# so they're easy to see in small plots in papers.
set style line 1 lc rgb "#A00000" pt 7
set style line 2 lc rgb "#00A000" pt 7
set style line 3 lc rgb "#5060D0" pt 7
set style line 4 lc rgb "#F25900" pt 7
# Let gnuplot decide the color, if more than 4 lines
set style line 5 pt 7
set style line 6 pt 7
set style line 7 pt 7
set style line 8 pt 7

set output outputname
set xlabel "ops/sec"
set ylabel "epsilon (%)"

set key right top

set datafile missing '0'

# log scale on the y axis
# set logscale y 2
# set format y ""
# set ytics 1e-6, 10, 1
# set ytics add ("1" 1, ".1" 0.1, ".01" 0.01, "10^-3" 0.001, \
#                "10^-4" 0.0001)
# set mytics 10

set xrange [0:*]
set yrange [0:*]

# set xrange [0:60]
# set yrange [0.5:64]

# Titles with spaces are not allowed
# These titles should be separated by "_" and here we replace by " "
pretty(title) = system("echo ".title." | sed 's/_/ /g'")

# Input file contains comma-separated values fields
set datafile separator ","

plot for [i=0:words(inputnames) - 1] word(inputnames, i + 1) using 1:2:3 with linespoint ls i + 1 title pretty(word(titles, i + 1))
replot for [i=0:words(inputnames) - 1] word(inputnames, i + 1) using 1:2:3 with labels offset char 1,0 notitle

# Note you need gnuplot 4.4 for the pdfcairo terminal.

# set terminal pdfcairo font "Gill Sans,9" linewidth 4 rounded fontscale 1.0
set terminal pdfcairo font "Gill Sans,7" linewidth 1 rounded fontscale 1.0

# Line style for axes
set style line 80 lt rgb "#808080"

# Line style for grid
set style line 81 lt 0  # dashed
set style line 81 lt rgb "#808080"  # grey

set grid back linestyle 81
set border 3 back linestyle 80 # Remove border on top and right.  These
             # borders are useless and make it harder
             # to see plotted lines near the border.
    # Also, put it in grey; no need for so much emphasis on a border.
# set xtics nomirror
# set ytics nomirror

#set log y
#set mxtics 10    # Makes logscale look good.

# Line styles: try to pick pleasing colors, rather
# than strictly primary colors or hard-to-see colors

# like gnuplot's default yellow.  Make the lines thick
# so they're easy to see in small plots in papers.
set style line 1 lc rgb "#A00000" pt 7
set style line 2 lc rgb "#00A000" pt 7
set style line 3 lc rgb "#5060D0" pt 7
set style line 4 lc rgb "#F25900" pt 7
# Let gnuplot decide the color, if more than 4 lines
set style line 5 pt 7
set style line 6 pt 7
set style line 7 pt 7
set style line 8 pt 7

set output outputname
set xlabel "ops/sec"
set ylabel "epsilon (%)"

set key left top

set datafile missing '0'

# log scale on the y axis
# set logscale y 2
# set format y ""
# set ytics 1e-6, 10, 1
# set ytics add ("1" 1, ".1" 0.1, ".01" 0.01, "10^-3" 0.001, \
#                "10^-4" 0.0001)
# set mytics 10

set xrange [0:*]
set yrange [0:*]

# set xrange [0:60]
# set yrange [0.5:64]

# Titles with spaces are not allowed
# These titles should be separated by "_" and here we replace by " "
pretty(title) = system("echo ".title." | sed 's/_/ /g'")

# Input file contains comma-separated values fields
set datafile separator ","

plot for [i=0:words(inputnames) - 1] word(inputnames, i + 1) using 1:2:3 with linespoint ls i + 1 title pretty(word(titles, i + 1))
replot for [i=0:words(inputnames) - 1] word(inputnames, i + 1) using 1:2:3 with labels offset char 1,0 notitle


fix plot labels, increased line offset -- #504

# '#FF9944'
# '#AA6666'
# '#FF9944'
# '#AA6666'
# '#FF9944'
# '#AA6666'
# '#AA6666'
#
# '#99FF44'
# '#66AA66'
# '#99FF44'
# '#66AA66'
# '#99FF44'
# '#66AA66'
# '#66AA66'
#
# '#9944FF'
# '#6666AA'
# '#9944FF'
# '#6666AA'
# '#9944FF'
# '#6666AA'
# '#6666AA'

# print 'plot title   : ' . plottitle
# print 'session id   : ' . session
# print 'max time     : ' . maxtime
# print 'timetics     : ' . timetics
# print 'maxslots     : ' . maxslots
# print 'pilotnum     : ' . pilotnum
# print 'nodesize     : ' . nodesize

print 'pilot_num       : ' . pilot_num
print 'pilot_id_list   : ' . pilot_id_list
print 'pilot_name_list : ' . pilot_name_list

pilot_states_dat_list    = ''
pilot_callbacks_dat_list = ''
pilot_slots_dat_list     = ''
pilot_queue_dat_list     = ''
unit_states_dat_list     = ''
unit_callbacks_dat_list  = ''
offset_list              = ''

color_list_1 = "#FF8855 #88FF55 #8855FF #FF55FF #55FFFF"
color_list_2 = "#AA8855 #88AA55 #8855AA #AA55AA #55AAAA"

do for [i=1:pilot_num] {
    pilot_id = word(pilot_id_list, i)

    print ''
    print 'pilot name      : '  . word(pilot_name_list, i)
    print 'pilot id        : '  . pilot_id

    pilot_states_dat         = '/tmp/rp.' . session . '.pilot.states.'    . pilot_id . '.dat'
    pilot_callbacks_dat      = '/tmp/rp.' . session . '.pilot.callbacks.' . pilot_id . '.dat'
    pilot_slots_dat          = '/tmp/rp.' . session . '.pilot.slots.'     . pilot_id . '.dat'
    pilot_queue_dat          = '/tmp/rp.' . session . '.pilot.queue.'     . pilot_id . '.dat'
    unit_states_dat          = '/tmp/rp.' . session . '.unit.states.'     . pilot_id . '.dat'
    unit_callbacks_dat       = '/tmp/rp.' . session . '.unit.callbacks.'  . pilot_id . '.dat'

    pilot_states_dat_list    = pilot_states_dat_list    . pilot_states_dat    . ' '
    pilot_callbacks_dat_list = pilot_callbacks_dat_list . pilot_callbacks_dat . ' '
    pilot_slots_dat_list     = pilot_slots_dat_list     . pilot_slots_dat     . ' '
    pilot_queue_dat_list     = pilot_queue_dat_list     . pilot_queue_dat     . ' '
    unit_states_dat_list     = unit_states_dat_list     . unit_states_dat     . ' '
    unit_callbacks_dat_list  = unit_callbacks_dat_list  . unit_callbacks_dat  . ' '

}

offset(i,n) = (i * n)  -  (pilot_num / 2 * n)
hex(i)      = "0123456789ABCDEF"[i:i]
hexx(i)     = hex(i).hex(i)
color_1(i)  = word(color_list_1,i)
color_2(i)  = word(color_list_2,i)
get_title(i)= sprintf("%s: %-15s (%s cores)", word(pilot_id_list,i), word(pilot_name_list,i), word(slotnum_list,i))

# print 'palette '
# do for [i=1:pilot_num] {
#     print  '        ' . color_1(i) . '  ' . color_2(i)
# }
#
# print 'offsets'
# do for [i=1:pilot_num] {
#     print  '        ' . sprintf ("%f", offset (i, 0.2))
#     print word(slotnum_list,i)+offset(i,0.5)
# }
#
# print 'pilot_queue_dats'
# do for [i=1:pilot_num] {
#     print word(pilot_queue_dat_list,i)
# }

do for [term_i=1:words(terms)] {
    term = word(terms, term_i)
    term_t = term.'cairo'

    # --------------------------------------------------------------------------------------------------
    #
    # base parameters
    #
    set key Left left

    if (term eq 'pdf') {
        term_mult  = 6.0
        term_x     = 70
        term_y     = 70
        term_font  = 'Monospace,6'
        term_dl    = 7
        term_lw    = 3

        set key    font ",6"
        set xlabel font ",6"
        set ylabel font ",6"
        set title  font ",6"

    } else {
        term_mult  = 6.0
        term_x     = '6000'
        term_y     = '6000'
        term_font  = 'Monospace,8'
        term_dl    = 6
        term_lw    = 1

        set key    font ",8"
        set xlabel font ",8"
        set ylabel font ",8"
        set title  font ",8"
    }

    # pilot 1: pilot states, pilot notifications
    #          unit states, unit state notifications,
    #          slots, maxslots
    set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 101 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 102 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 103 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 104 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 105 lt 2 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 106 lt 1 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*2

    set style line 200 lt 1 lc rgb '#99FF44' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 201 lt 1 lc rgb '#66AA66' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 202 lt 1 lc rgb '#99FF44' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 203 lt 1 lc rgb '#66AA66' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 204 lt 1 lc rgb '#99FF44' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 205 lt 2 lc rgb '#66AA66' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 206 lt 1 lc rgb '#66AA66' pt 7 ps term_mult*0.6 lw term_mult*2

    set style line 300 lt 1 lc rgb '#9944FF' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 301 lt 1 lc rgb '#6666AA' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 302 lt 1 lc rgb '#9944FF' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 303 lt 1 lc rgb '#6666AA' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 304 lt 1 lc rgb '#9944FF' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 305 lt 2 lc rgb '#6666AA' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 306 lt 1 lc rgb '#6666AA' pt 7 ps term_mult*0.6 lw term_mult*2

  # set mxtics     10
  # set mytics     10
    set tics       scale 1.5

    set term       term_t enhanced color dashed \
        size       term_x,term_y \
        font       term_font     \
        fontscale  term_mult     \
        dashlength term_dl       \
        linewidth  term_lw

    # --------------------------------------------------------------------------------------------------
    set output './'.sname.'.'.term
    print      './'.sname.'.'.term

    set title  ''

    set tmargin  0
    set bmargin  0
    set lmargin 25
    set rmargin 10
    set border  lw 4.0

  unset y2label
  unset y2tics
  unset y2range

  # set size 1.0,1.5
    set multiplot layout 4,1 title "\n\n" . plottitle . "\n\n\n\n"

    # ------------------------------------------------------------------------------------
    set xrange [0:maxtime]
    set xtics  timetics
  # set mxtics mtimetics
    set yrange [0:8]
    set ytics  ("PENDING LAUNCH" 1, \
                "LAUNCHING     " 2, \
                "PENDING ACTIVE" 3, \
                "ACTIVE        " 4, \
                "DONE          " 5, \
                "CANCELED      " 6, \
                "FAILED        " 7)
    set xlabel  ''
    set ylabel "PILOTS\n[states]" offset second -0.06,0
    set format x ""
    set grid

  # set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
  # set style line 101 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    plot for [i=1:pilot_num] \
         word(pilot_states_dat_list,i)    using 1:($2+offset(i,0.05))      title '' with steps  lt 1 lc rgb color_1(i) lw term_mult*2, \
         for [i=1:pilot_num] \
         word(pilot_callbacks_dat_list,i) using 1:($2+offset(i,0.05)+0.05) title '' with points lt 1 lc rgb color_2(i) lw term_mult*1

    # ------------------------------------------------------------------------------------
    set xrange [0:maxtime]
    set yrange [0:12]
    set ytics  ("NEW            "  1, \
                "SCHEDULING     "  2, \
                "PEND.   INPUT  "  3, \
                "TRANSF. INPUT  "  4, \
                "PEND. EXECUTION"  5, \
                "ALLOCATING     "  6, \
                "EXECUTING      "  7, \
                "PEND.   OUTPUT "  8, \
                "TRANSF. OUTPUT "  9, \
                "DONE           " 10, \
                "CANCELED       " 11, \
                "FAILED         " 12)

    set xlabel ''
    set ylabel "UNITS\n[states]" offset second -0.06,0
    set format x ""
    set grid

  # set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
  # set style line 101 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    plot for [i=1:pilot_num] \
         word(unit_states_dat_list,i)    using 1:($2+offset(i,0.05))      title '' with steps  lt 1 lc rgb color_1(i) lw term_mult*2, \
         for [i=1:pilot_num] \
         word(unit_callbacks_dat_list,i) using 1:($2+offset(i,0.05)+0.05) title '' with points lt 1 lc rgb color_2(i) lw term_mult*1

    # ------------------------------------------------------------------------------------
    set xrange  [0:maxtime]
    set yrange  [0:slotsscale]
    set mytics  nodesize
    set ytics   autofreq nomirror
    set mytics  0
    set y2tics  autofreq
    set y2range [0:queuescale]
    set my2tics 0

    set xlabel  'time (in seconds)'
    set ylabel  "PILOT ACTIVITY\n[slots / queue]" offset second -00,0
    set y2label "UNIT WAIT QUEUE SIZE"            offset second -00.0,0
    set grid
  unset format

  # set style line 104 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*3
  # set style line 106 lt 1 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*2
  # set style line 105 lt 2 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*3
    plot for [i=1:pilot_num] \
         word(pilot_slots_dat_list,i) using 1:($2+offset(i,0.25))     title '' with steps  lt 1 lc rgb color_1(i) lw term_mult*3, \
         for [i=1:pilot_num] \
         word(pilot_queue_dat_list,i) using 1:($2+offset(i,0.1)+0.25) title '' with steps  lt 1 lc rgb color_2(i) lw term_mult*2 axes x1y2 , \
         for [i=1:pilot_num] \
         word(slotnum_list,i)+0+word(slotnum_list,i)*0.25*offset(i,1) title '' with lines  lt 2 lc rgb color_1(i) lw term_mult*3

    # ------------------------------------------------------------------------------------
    # Key plot
    set   tmargin 7
    set   lmargin 24
    set   border  lw 0
    unset tics
    unset xlabel
    set   ylabel ""# "Legend and\nStatistics" offset second -17,0
    set   yrange [0:1]
  unset y2label
  unset y2tics
  unset y2range

    set   key top left reverse maxrows 7

  # set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
    plot for [i=1:pilot_num] \
         NaN with lines title get_title(i) lt 1 lc rgb color_1(i) lw term_mult*2

#   plot NaN lw   0 t 'PILOT 1 ('.pilot_1_name.'):'                      , \
#        NaN ls 100 t 'pilot/unit states changes'                        , \
#        NaN ls 101 t 'pilot/unit states notifications'                  , \
#        NaN ls 104 t 'busy slot (i.e. used CPU core)'                   , \
#        NaN ls 105 t 'total number of slots'                            , \
#        NaN ls 106 t 'unit queue length'                                , \
#        NaN lw   0 t ' '
#   }

    unset multiplot
}

# ------------------------------------------------------------------------------
# vim: ft=gnuplot

# '#FF9944'
# '#AA6666'
# '#FF9944'
# '#AA6666'
# '#FF9944'
# '#AA6666'
# '#AA6666'
#
# '#99FF44'
# '#66AA66'
# '#99FF44'
# '#66AA66'
# '#99FF44'
# '#66AA66'
# '#66AA66'
#
# '#9944FF'
# '#6666AA'
# '#9944FF'
# '#6666AA'
# '#9944FF'
# '#6666AA'
# '#6666AA'

# print 'plot title   : ' . plottitle
# print 'session id   : ' . session
# print 'max time     : ' . maxtime
# print 'timetics     : ' . timetics
# print 'maxslots     : ' . maxslots
# print 'pilotnum     : ' . pilotnum
# print 'nodesize     : ' . nodesize

print 'pilot_num       : ' . pilot_num
print 'pilot_id_list   : ' . pilot_id_list
print 'pilot_name_list : ' . pilot_name_list

pilot_states_dat_list    = ''
pilot_callbacks_dat_list = ''
pilot_slots_dat_list     = ''
pilot_queue_dat_list     = ''
unit_states_dat_list     = ''
unit_callbacks_dat_list  = ''
offset_list              = ''

color_list_1 = "#FF8855 #88FF55 #8855FF #FF55FF #55FFFF"
color_list_2 = "#AA8855 #88AA55 #8855AA #AA55AA #55AAAA"

do for [i=1:pilot_num] {
    pilot_id = word(pilot_id_list, i)

    print ''
    print 'pilot name      : '  . word(pilot_name_list, i)
    print 'pilot id        : '  . pilot_id

    pilot_states_dat         = '/tmp/rp.' . session . '.pilot.states.'    . pilot_id . '.dat'
    pilot_callbacks_dat      = '/tmp/rp.' . session . '.pilot.callbacks.' . pilot_id . '.dat'
    pilot_slots_dat          = '/tmp/rp.' . session . '.pilot.slots.'     . pilot_id . '.dat'
    pilot_queue_dat          = '/tmp/rp.' . session . '.pilot.queue.'     . pilot_id . '.dat'
    unit_states_dat          = '/tmp/rp.' . session . '.unit.states.'     . pilot_id . '.dat'
    unit_callbacks_dat       = '/tmp/rp.' . session . '.unit.callbacks.'  . pilot_id . '.dat'

    pilot_states_dat_list    = pilot_states_dat_list    . pilot_states_dat    . ' '
    pilot_callbacks_dat_list = pilot_callbacks_dat_list . pilot_callbacks_dat . ' '
    pilot_slots_dat_list     = pilot_slots_dat_list     . pilot_slots_dat     . ' '
    pilot_queue_dat_list     = pilot_queue_dat_list     . pilot_queue_dat     . ' '
    unit_states_dat_list     = unit_states_dat_list     . unit_states_dat     . ' '
    unit_callbacks_dat_list  = unit_callbacks_dat_list  . unit_callbacks_dat  . ' '

}

offset(i,n) = (i * n)  -  (pilot_num / 2 * n)
hex(i)      = "0123456789ABCDEF"[i:i]
hexx(i)     = hex(i).hex(i)
color_1(i)  = word(color_list_1,i)
color_2(i)  = word(color_list_2,i)
get_title(i)= sprintf("%s: %-15s (%s cores)", word(pilot_id_list,i), word(pilot_name_list,i), word(slotnum_list,i))

# print 'palette '
# do for [i=1:pilot_num] {
#     print  '        ' . color_1(i) . '  ' . color_2(i)
# }
#
# print 'offsets'
# do for [i=1:pilot_num] {
#     print  '        ' . sprintf ("%f", offset (i, 0.2))
#     print word(slotnum_list,i)+offset(i,0.5)
# }
#
# print 'pilot_queue_dats'
# do for [i=1:pilot_num] {
#     print word(pilot_queue_dat_list,i)
# }

do for [term_i=1:words(terms)] {
    term = word(terms, term_i)
    term_t = term.'cairo'

    # --------------------------------------------------------------------------------------------------
    #
    # base parameters
    #
    set key Left left

    if (term eq 'pdf') {
        term_mult  = 6.0
        term_x     = 70
        term_y     = 70
        term_font  = 'Monospace,6'
        term_dl    = 7
        term_lw    = 3

        set key    font ",6"
        set xlabel font ",6"
        set ylabel font ",6"
        set title  font ",6"

    } else {
        term_mult  = 6.0
        term_x     = '6000'
        term_y     = '6000'
        term_font  = 'Monospace,8'
        term_dl    = 6
        term_lw    = 1

        set key    font ",8"
        set xlabel font ",8"
        set ylabel font ",8"
        set title  font ",8"
    }

    # pilot 1: pilot states, pilot notifications
    #          unit states, unit state notifications,
    #          slots, maxslots
    set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 101 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 102 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 103 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 104 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 105 lt 2 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 106 lt 1 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*2

    set style line 200 lt 1 lc rgb '#99FF44' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 201 lt 1 lc rgb '#66AA66' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 202 lt 1 lc rgb '#99FF44' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 203 lt 1 lc rgb '#66AA66' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 204 lt 1 lc rgb '#99FF44' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 205 lt 2 lc rgb '#66AA66' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 206 lt 1 lc rgb '#66AA66' pt 7 ps term_mult*0.6 lw term_mult*2

    set style line 300 lt 1 lc rgb '#9944FF' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 301 lt 1 lc rgb '#6666AA' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 302 lt 1 lc rgb '#9944FF' pt 7 ps term_mult*0.6 lw term_mult*2
    set style line 303 lt 1 lc rgb '#6666AA' pt 6 ps term_mult*0.4 lw term_mult*1
    set style line 304 lt 1 lc rgb '#9944FF' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 305 lt 2 lc rgb '#6666AA' pt 7 ps term_mult*0.6 lw term_mult*3
    set style line 306 lt 1 lc rgb '#6666AA' pt 7 ps term_mult*0.6 lw term_mult*2

  # set mxtics     10
  # set mytics     10
    set tics       scale 1.5

    set term       term_t enhanced color dashed \
        size       term_x,term_y \
        font       term_font     \
        fontscale  term_mult     \
        dashlength term_dl       \
        linewidth  term_lw

    # --------------------------------------------------------------------------------------------------
    set output './'.sname.'.'.term
    print      './'.sname.'.'.term

    set title  ''

    set tmargin  0
    set bmargin  0
    set lmargin 25
    set rmargin 10
    set border  lw 4.0

  # set size 1.0,1.5
    set multiplot layout 4,1 title "\n\n" . plottitle . "\n\n\n\n"

    # ------------------------------------------------------------------------------------
    set xrange [0:maxtime]
    set xtics  timetics
  # set mxtics mtimetics
    set yrange [0:8]
    set ytics  ("PENDING LAUNCH" 1, \
                "LAUNCHING     " 2, \
                "PENDING ACTIVE" 3, \
                "ACTIVE        " 4, \
                "DONE          " 5, \
                "CANCELED      " 6, \
                "FAILED        " 7)
    set xlabel  ''
    set ylabel "PILOTS\n[states]" offset second -0.06,0
    set format x ""
    set grid

  # set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
  # set style line 101 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    plot for [i=1:pilot_num] \
         word(pilot_states_dat_list,i)    using 1:($2+offset(i,0.05))      title '' with steps  lt 1 lc rgb color_1(i) lw term_mult*2, \
         for [i=1:pilot_num] \
         word(pilot_callbacks_dat_list,i) using 1:($2+offset(i,0.05)+0.05) title '' with points lt 1 lc rgb color_2(i) lw term_mult*1

    # ------------------------------------------------------------------------------------
    set xrange [0:maxtime]
    set yrange [0:12]
    set ytics  ("NEW            "  1, \
                "SCHEDULING     "  2, \
                "PEND.   INPUT  "  3, \
                "TRANSF. INPUT  "  4, \
                "PEND. EXECUTION"  5, \
                "ALLOCATING     "  6, \
                "EXECUTING      "  7, \
                "PEND.   OUTPUT "  8, \
                "TRANSF. OUTPUT "  9, \
                "DONE           " 10, \
                "CANCELED       " 11, \
                "FAILED         " 12)

    set xlabel ''
    set ylabel "UNITS\n[states]" offset second -0.06,0
    set format x ""
    set grid

  # set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
  # set style line 101 lt 1 lc rgb '#AA6666' pt 6 ps term_mult*0.4 lw term_mult*1
    plot for [i=1:pilot_num] \
         word(unit_states_dat_list,i)    using 1:($2+offset(i,0.05))      title '' with steps  lt 1 lc rgb color_1(i) lw term_mult*2, \
         for [i=1:pilot_num] \
         word(unit_callbacks_dat_list,i) using 1:($2+offset(i,0.05)+0.05) title '' with points lt 1 lc rgb color_2(i) lw term_mult*1

    # ------------------------------------------------------------------------------------
    set xrange  [0:maxtime]
    set yrange  [0:slotsscale]
    set mytics  nodesize
    set ytics   autofreq nomirror
    set mytics  0
    set y2tics  autofreq
    set y2range [0:queuescale]
    set my2tics 0

    set xlabel  'time (in seconds)'
    set ylabel  "PILOT ACTIVITY\n[slots / queue]" offset second -11,0
    set y2label "UNIT WAIT QUEUE SIZE"            offset second -00,0
    set grid
  unset format

  # set style line 104 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*3
  # set style line 106 lt 1 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*2
  # set style line 105 lt 2 lc rgb '#AA6666' pt 7 ps term_mult*0.6 lw term_mult*3
    plot for [i=1:pilot_num] \
         word(pilot_slots_dat_list,i) using 1:($2+offset(i,0.1))      title '' with steps  lt 1 lc rgb color_1(i) lw term_mult*3, \
         for [i=1:pilot_num] \
         word(pilot_queue_dat_list,i) using 1:($2+offset(i,0.1)+0.05) title '' with steps  lt 1 lc rgb color_2(i) lw term_mult*2 axes x1y2 , \
         for [i=1:pilot_num] \
         word(slotnum_list,i)+0+word(slotnum_list,i)*0.05*offset(i,1) title '' with lines  lt 2 lc rgb color_1(i) lw term_mult*3

      # ------------------------------------------------------------------------------------
      # Key plot
      set   tmargin 7
      set   lmargin 24
      set   border  lw 0
      unset tics
      unset xlabel
      set   ylabel ""# "Legend and\nStatistics" offset second -17,0
      set   yrange [0:1]

      set   key top left reverse maxrows 7

    # set style line 100 lt 1 lc rgb '#FF9944' pt 7 ps term_mult*0.6 lw term_mult*2
      plot for [i=1:pilot_num] \
           NaN with lines title get_title(i) lt 1 lc rgb color_1(i) lw term_mult*2

#     plot NaN lw   0 t 'PILOT 1 ('.pilot_1_name.'):'                      , \
#          NaN ls 100 t 'pilot/unit states changes'                        , \
#          NaN ls 101 t 'pilot/unit states notifications'                  , \
#          NaN ls 104 t 'busy slot (i.e. used CPU core)'                   , \
#          NaN ls 105 t 'total number of slots'                            , \
#          NaN ls 106 t 'unit queue length'                                , \
#          NaN lw   0 t ' '
#     }

    unset multiplot
}

# ------------------------------------------------------------------------------
# vim: ft=gnuplot