From 05f5111e9715cc9ce89860939492b829fa990a42 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 6 Apr 2017 12:04:12 +0200 Subject: plot_param_fit: improve output graphs for num0/num1 and other non-monotonous functions --- lib/plotter.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/plotter.py b/lib/plotter.py index 763fae5..784ba56 100755 --- a/lib/plotter.py +++ b/lib/plotter.py @@ -75,7 +75,14 @@ def plot_param_fit(function, name, fitfunc, funp, parameters, datatype, index, X fig, ax1 = plt.subplots(figsize=(10,6)) fig.canvas.set_window_title("fit %s" % (function)) plt.subplots_adjust(left=0.14, right=0.99, top=0.99, bottom=0.14) - xsp = np.linspace(X[index].min(), X[index].max(), 100) + + x_range = X[index].max() - X[index].min() + 1 + + if x_range > 100 and x_range < 500: + xsp = np.linspace(X[index].min(), X[index].max(), x_range) + else: + xsp = np.linspace(X[index].min(), X[index].max(), 100) + x_range = 100 if xaxis != None: ax1.set_xlabel(xaxis) @@ -101,9 +108,9 @@ def plot_param_fit(function, name, fitfunc, funp, parameters, datatype, index, X plt.plot(X[index][tt], Y[tt], "rx", color=color) - xarg = [np.array([x] * 100) for x in elem[:index]] + xarg = [np.array([x] * x_range) for x in elem[:index]] xarg.append(xsp) - xarg.extend([np.array([x] * 100) for x in elem[index:]]) + xarg.extend([np.array([x] * x_range) for x in elem[index:]]) plt.plot(xsp, fitfunc(funp, xarg), "r-", color=color) plt.show() -- cgit v1.2.3