From 1b00c99a236bd3729b29efe9b43b20d4f42330ef Mon Sep 17 00:00:00 2001
From: Antonio Ospite <ao2@ao2.it>
Date: Thu, 29 Nov 2018 11:31:24 +0100
Subject: [PATCH 1/1] Fix errors with recent gnuplot versions

It looks like recent gnuplot versions do not keep variables around when
they get out of scope, like a counter used only inside a loop.

This results in some errors in the modular scripts:

  ./modular_cartesian.gnuplot", line 62: undefined variable: i
  ./modular_polar.gnuplot", line 59: undefined variable: i

Fix this by using 'year_max' instead of 'i' outside of the loop where
'i' was defined.

Since 'year_max' is a float variable string concatenation would not work
with it, resulting in the following errors:

  ./modular_cartesian.gnuplot", line 62: internal error : STRING operator applied to undefined or non-STRING variable
  ./modular_polar.gnuplot", line 59: internal error : STRING operator applied to undefined or non-STRING variable

So while at it also convert the float to an integer so that the result
can be used with the string concatenation operator.
---
 modular_cartesian.gnuplot | 2 +-
 modular_polar.gnuplot     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modular_cartesian.gnuplot b/modular_cartesian.gnuplot
index 07f7aeb..574806c 100755
--- a/modular_cartesian.gnuplot
+++ b/modular_cartesian.gnuplot
@@ -59,7 +59,7 @@ cblabels = 'set cbtics ( '
 do for [i=year_min:year_max] {
    cblabels = cblabels . '"' . i .'" ' . i .','
 }
-cblabels = cblabels . '"" ' . (i + 1) .','
+cblabels = cblabels . '"" ' . int(year_max + 1) .','
 cblabels = cblabels . ' )'
 eval(cblabels)
 
diff --git a/modular_polar.gnuplot b/modular_polar.gnuplot
index 4c00f2f..2007101 100755
--- a/modular_polar.gnuplot
+++ b/modular_polar.gnuplot
@@ -56,7 +56,7 @@ cblabels = 'set cbtics ( '
 do for [i=year_min:year_max] {
    cblabels = cblabels . '"' . i .'" ' . i .','
 }
-cblabels = cblabels . '"" ' . (i + 1) .','
+cblabels = cblabels . '"" ' . int(year_max + 1) .','
 cblabels = cblabels . ' )'
 eval(cblabels)
 
-- 
2.1.4