From 8a35a5e6cb3d9368233af5c39ab17702e5dbbe44 Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Sun, 2 Apr 2023 17:40:23 +0200 Subject: [PATCH] show sub-functions in fitresult; closes #26 --- src/gui_qt/fit/result.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gui_qt/fit/result.py b/src/gui_qt/fit/result.py index 43e63e0..92a4f74 100644 --- a/src/gui_qt/fit/result.py +++ b/src/gui_qt/fit/result.py @@ -1,6 +1,6 @@ from math import isnan -from pyqtgraph import mkBrush +from pyqtgraph import mkBrush, mkPen from nmreval.utils.text import convert @@ -160,6 +160,11 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): res = self._results[idx] iscomplex = res.iscomplex + sub_funcs = res.sub(res.x) + for item in self.fitplot.curves[::-1]: + if item not in [self.data_graph, self.data_graph_imag, self.fit_graph, self.fit_graph_imag]: + self.fitplot.removeItem(item) + if iscomplex: self.data_graph.setData(x=res.x_data, y=res.y_data.real) self.data_graph_imag.setData(x=res.x_data, y=res.y_data.imag) @@ -167,6 +172,13 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.fit_graph_imag.setData(x=res.x, y=res.y.imag) self.resid_graph.setData(x=res.x_data, y=res.residual.real) self.resid_graph_imag.setData(x=res.x_data, y=res.residual.imag) + + for f in sub_funcs: + item = PlotItem(x=f.x, y=f.y.real) + self.fitplot.addItem(item) + item = PlotItem(x=f.x, y=f.y.imag) + self.fitplot.addItem(item) + else: self.resid_graph.setData(x=res.x_data, y=res.residual) self.resid_graph_imag.setData(x=[], y=[]) @@ -175,6 +187,10 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): self.fit_graph.setData(x=res.x, y=res.y) self.fit_graph_imag.setData(x=[], y=[]) + for f in sub_funcs: + item = PlotItem(x=f.x, y=f.y, pen=mkPen({'style': 2})) + self.fitplot.addItem(item) + self.fitplot.setLogMode(x=res.islog) self.residplot.setLogMode(x=res.islog) @@ -279,7 +295,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog): plot_fits = self.curve_checkbox.isChecked() - parts = self.partial_checkBox.checkState() == QtCore.Qt.Checked extrapolate = [None, None, None]