From 6cb1e9864703ec0932a34d17be08ec4b01ed24b7 Mon Sep 17 00:00:00 2001 From: Fabian Joswig Date: Wed, 6 Apr 2022 16:02:10 +0100 Subject: [PATCH] fix: automatic range of residual_plot improved. --- pyerrors/fits.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pyerrors/fits.py b/pyerrors/fits.py index ea6bbe25..420d3da0 100644 --- a/pyerrors/fits.py +++ b/pyerrors/fits.py @@ -635,9 +635,10 @@ def qqplot(x, o_y, func, p): def residual_plot(x, y, func, fit_res): """ Generates a plot which compares the fit to the data and displays the corresponding residuals""" - xstart = x[0] - 0.5 - xstop = x[-1] + 0.5 - x_samples = np.arange(xstart, xstop, 0.01) + sorted_x = sorted(x) + xstart = sorted_x[0] - 0.5 * (sorted_x[1] - sorted_x[0]) + xstop = sorted_x[-1] + 0.5 * (sorted_x[-1] - sorted_x[-2]) + x_samples = np.arange(xstart, xstop + 0.01, 0.01) plt.figure(figsize=(8, 8 / 1.618)) gs = gridspec.GridSpec(2, 1, height_ratios=[3, 1], wspace=0.0, hspace=0.0)