[plotter] make it possible to fit even if yerr_kind is None
This commit is contained in:
+2
-2
@@ -1130,7 +1130,7 @@ class Plotter(Aggregator, BaseProcessor):
|
|||||||
Add an overlay : fit a curve, linear or powerlaw
|
Add an overlay : fit a curve, linear or powerlaw
|
||||||
"""
|
"""
|
||||||
if kind == "linear":
|
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)
|
(a, b, rho, _map_rule, stderr) = linregress(x, y)
|
||||||
self._log(
|
self._log(
|
||||||
"Linear fit y = {} x + {} with R^2 = {} and error is {}".format(
|
"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)
|
label = r"Linear fit with slope ${:.3g}$".format(a)
|
||||||
plt.plot(x, a * x + b, label=label, **kwargs)
|
plt.plot(x, a * x + b, label=label, **kwargs)
|
||||||
elif kind == "power_law":
|
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))
|
(a, b, rho, _map_rule, stderr) = linregress(np.log10(x), np.log10(y))
|
||||||
self._log(
|
self._log(
|
||||||
"Power law fit y = x^({}) * {} with R^2 = {} and error is {}".format(
|
"Power law fit y = x^({}) * {} with R^2 = {} and error is {}".format(
|
||||||
|
|||||||
Reference in New Issue
Block a user