From 92d6c66af53016d5b655a7409673ac345f0bd8d0 Mon Sep 17 00:00:00 2001 From: Noe Brucy Date: Wed, 3 Feb 2021 19:25:15 +0100 Subject: [PATCH] [plotter] make it possible to fit even if yerr_kind is None --- plotter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plotter.py b/plotter.py index dd5749c..e741397 100644 --- a/plotter.py +++ b/plotter.py @@ -1130,7 +1130,7 @@ class Plotter(Aggregator, BaseProcessor): Add an overlay : fit a curve, linear or powerlaw """ if kind == "linear": - if yerr is None: + if yerr is None or np.sum(np.abs(yerr)) == 0: (a, b, rho, _map_rule, stderr) = linregress(x, y) self._log( "Linear fit y = {} x + {} with R^2 = {} and error is {}".format( @@ -1153,7 +1153,7 @@ class Plotter(Aggregator, BaseProcessor): label = r"Linear fit with slope ${:.3g}$".format(a) plt.plot(x, a * x + b, label=label, **kwargs) elif kind == "power_law": - if yerr is None: + if yerr is None or np.sum(np.abs(yerr)) == 0: (a, b, rho, _map_rule, stderr) = linregress(np.log10(x), np.log10(y)) self._log( "Power law fit y = x^({}) * {} with R^2 = {} and error is {}".format(