From d53c0e88c6f8dd78dcbee103e52cf99849b4115b Mon Sep 17 00:00:00 2001
From: "Andrew E. Torda" <torda@zbh.uni-hamburg.de>
Date: Wed, 9 Mar 2022 18:26:33 +0100
Subject: [PATCH] Work around quirk in plotting library. If you do not put
 something on the primary yaxis, the scaling on secondary axis does not work.

---
 examples/example2  |  6 +++---
 mc_work/mc_work.go |  2 ++
 mc_work/plot.go    | 35 ++++++++++++++---------------------
 mc_work/rdprm.go   |  2 +-
 4 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/examples/example2 b/examples/example2
index 97d78b7..9824ead 100644
--- a/examples/example2
+++ b/examples/example2
@@ -1,8 +1,8 @@
-# This one is for debugging, rather than anything serious.
+# This one is a constant temperature run
 ini_temp 0.08
 final_temp 0.08
-n_step 1000
+n_step 100000
 x_ini 4,4
 x_delta 0.5
 seed 1637
-foutname ex1.csv # This will store all the information from a run.
\ No newline at end of file
+foutname ex2.csv # This will store all the information from a run.
\ No newline at end of file
diff --git a/mc_work/mc_work.go b/mc_work/mc_work.go
index a63d31c..f53335d 100644
--- a/mc_work/mc_work.go
+++ b/mc_work/mc_work.go
@@ -31,3 +31,5 @@ type MCresult struct {
 	Bestfval     float64   // best function value found
 	BestX        []float32 // location of this best value found
 }
+
+func breaker(...interface{}) {}
diff --git a/mc_work/plot.go b/mc_work/plot.go
index f3373e9..4f20ee4 100644
--- a/mc_work/plot.go
+++ b/mc_work/plot.go
@@ -147,15 +147,6 @@ func plotfWrt(cprm *cprm) error {
 	return nil
 }
 
-func invisibleStyle() chart.Style {
-	return chart.Style{
-		StrokeColor: chart.ColorTransparent,
-		FontColor:   chart.ColorTransparent,
-		DotColor:    chart.ColorTransparent,
-		FillColor:   chart.ColorTransparent,
-	}
-}
-
 // For each dimension, allocate space. The X's are stored in a single
 // array, so here we allocate an array of arrays for each dimension and
 // copy the elements. We then take the graph object and toss out the first
@@ -179,20 +170,24 @@ func plotxWrt(cprm *cprm, ndim int) error {
 			n++
 		}
 	}
+
 	graph.Title = fmt.Sprintf("X trajectories %d dimension", ndim)
 	graph.YAxisSecondary.Name = "X coord"
-	{
-		if b, ok := graph.Series[0].(chart.ContinuousSeries); ok {
-			b.Style = invisibleStyle()
-			graph.Series[0] = b
-		} else {
-			panic("program bug type assertion on series 0")
-		}
+
+	if b, ok := graph.Series[0].(chart.ContinuousSeries); !ok {
+		panic("program bug type assertion on series 0")
+	} else {
+		b.Style.StrokeColor = chart.ColorTransparent
+		b.Style.FillColor = chart.ColorTransparent
+		graph.Series[0] = b
 	}
-	graph.YAxis.Style = invisibleStyle()
-	graph.YAxis.NameStyle = invisibleStyle()
+	graph.YAxis.Style.FontColor = chart.ColorTransparent
+	graph.YAxis.Style.StrokeColor = chart.ColorTransparent
+	graph.YAxis.NameStyle.FontColor = chart.ColorTransparent
 
-	if baseSeries, ok := graph.Series[1].(chart.ContinuousSeries); ok {
+	if baseSeries, ok := graph.Series[1].(chart.ContinuousSeries); !ok {
+		panic("program bug, type assertion on y axis xtrajectories")
+	} else {
 		graph.Series = graph.Series[:1]
 		for i := 0; i < ndim; i++ {
 			tmp := baseSeries
@@ -200,8 +195,6 @@ func plotxWrt(cprm *cprm, ndim int) error {
 			tmp.YValues = xdata[i]
 			graph.Series = append(graph.Series, tmp)
 		}
-	} else {
-		panic("program bug, type assertion on y axis xtrajectories")
 	}
 	if err := graph.Render(chart.PNG, cprm.xplotWrt); err != nil {
 		return fmt.Errorf("plotting X trajectories: %w", err)
diff --git a/mc_work/rdprm.go b/mc_work/rdprm.go
index 16dc3a2..6a8dc42 100644
--- a/mc_work/rdprm.go
+++ b/mc_work/rdprm.go
@@ -111,7 +111,7 @@ pairs. Values for x_ini are separated by commas without spaces.
 }
 
 // afterHash takes a string and removes anything after a hash (#) character
-func afterHash (s string) string {
+func afterHash(s string) string {
 	if i := strings.IndexByte(s, '#'); i == -1 {
 		return s
 	} else {
-- 
GitLab