show sub-functions in fitresult; closes #26

This commit is contained in:
Dominik Demuth 2023-04-02 17:40:23 +02:00
parent de9464ef9f
commit 8a35a5e6cb

View File

@ -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]