From 0794e4853081caa7875f02633b6dfc16bba9226c Mon Sep 17 00:00:00 2001 From: surtur Date: Fri, 8 Jul 2022 03:32:07 +0200 Subject: [PATCH] go(plot): set Y axis' min/max dynamically --- algo/plot.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/algo/plot.go b/algo/plot.go index 96dcb7f..ce3512f 100644 --- a/algo/plot.go +++ b/algo/plot.go @@ -8,6 +8,7 @@ import ( "log" "git.dotya.ml/wanderer/math-optim/stats" + "gonum.org/v1/gonum/floats" "gonum.org/v1/plot" "gonum.org/v1/plot/plotter" "gonum.org/v1/plot/plotutil" @@ -52,6 +53,9 @@ func plotAllDims(allStats []stats.Stats, fPrefix, fExt string) { // mark the end of the X axis with len(iter.Results). p.X.Max = float64(len(iter.Results)) + p.Y.Min = floats.Min(iter.Results) + p.Y.Max = floats.Max(iter.Results) + pts := make(plotter.XYs, len(iter.Results)) // fill the plotter with datapoints.