plot fit and residual together with bigger fit

This commit is contained in:
Dominik Demuth 2023-05-18 20:43:45 +02:00
parent 49101565a3
commit 67d60949b5
3 changed files with 16 additions and 31 deletions

View File

@ -14,7 +14,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(864, 712)
Dialog.resize(969, 974)
self.gridLayout = QtWidgets.QGridLayout(Dialog)
self.gridLayout.setObjectName("gridLayout")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
@ -153,18 +153,10 @@ class Ui_Dialog(object):
self.logx_box.setLayoutDirection(QtCore.Qt.RightToLeft)
self.logx_box.setObjectName("logx_box")
self.gridLayout_3.addWidget(self.logx_box, 2, 0, 1, 1)
self.fit_plot = PlotWidget(self.stackPage1)
self.fit_plot.setObjectName("fit_plot")
self.gridLayout_3.addWidget(self.fit_plot, 0, 0, 1, 2)
self.graphicsView = GraphicsLayoutWidget(self.stackPage1)
self.graphicsView.setObjectName("graphicsView")
self.gridLayout_3.addWidget(self.graphicsView, 0, 0, 1, 2)
self.stack.addTab(self.stackPage1, "")
self.tab = QtWidgets.QWidget()
self.tab.setObjectName("tab")
self.verticalLayout = QtWidgets.QVBoxLayout(self.tab)
self.verticalLayout.setObjectName("verticalLayout")
self.resid_plot = PlotWidget(self.tab)
self.resid_plot.setObjectName("resid_plot")
self.verticalLayout.addWidget(self.resid_plot)
self.stack.addTab(self.tab, "")
self.stackPage2 = QtWidgets.QWidget()
self.stackPage2.setObjectName("stackPage2")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.stackPage2)
@ -232,7 +224,6 @@ class Ui_Dialog(object):
self.logy_box.setText(_translate("Dialog", "logarithmic y axis"))
self.logx_box.setText(_translate("Dialog", "logarithmic x axis"))
self.stack.setTabText(self.stack.indexOf(self.stackPage1), _translate("Dialog", "Plot"))
self.stack.setTabText(self.stack.indexOf(self.tab), _translate("Dialog", "Residuals"))
self.stack.setTabText(self.stack.indexOf(self.stackPage2), _translate("Dialog", "Statistics"))
item = self.corr_tableWidget.horizontalHeaderItem(0)
item.setText(_translate("Dialog", "Parameter 1"))
@ -244,4 +235,4 @@ class Ui_Dialog(object):
item.setText(_translate("Dialog", "Partial Corr."))
self.stack.setTabText(self.stack.indexOf(self.stackPage3), _translate("Dialog", "Correlations"))
from ..lib.forms import ElideComboBox
from pyqtgraph import PlotWidget
from pyqtgraph import GraphicsLayoutWidget

View File

@ -33,6 +33,12 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
self.graph_opts = {}
self.last_idx = None
self.resid_plot = self.graphicsView.addPlot(row=0, col=0, title='Residual')
self.fit_plot = self.graphicsView.addPlot(row=1, col=0, title='Fit')
self.graphicsView.ci.layout.setRowStretchFactor(0, 1)
self.graphicsView.ci.layout.setRowStretchFactor(1, 2)
self.resid_graph = PlotItem(x=[], y=[],
symbol='o', symbolPen=None, symbolBrush=mkBrush(color=(31, 119, 180)),
pen=None)
@ -41,7 +47,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
pen=None)
self.resid_plot.addItem(self.resid_graph)
self.resid_plot.addItem(self.resid_graph_imag)
self.resid_plot.setLabel('left', 'Residual')
self.data_graph = PlotItem(x=[], y=[],
symbol='o', symbolPen=None, symbolBrush=mkBrush(color=(31, 119, 180)),
@ -51,7 +56,6 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
pen=None)
self.fit_plot.addItem(self.data_graph)
self.fit_plot.addItem(self.data_graph_imag)
self.fit_plot.setLabel('left', 'Function')
self.fit_graph = PlotItem(x=[], y=[])
self.fit_graph_imag = PlotItem(x=[], y=[])
@ -159,7 +163,7 @@ class QFitResult(QtWidgets.QDialog, Ui_Dialog):
iscomplex = res.iscomplex
sub_funcs = res.sub(res.x)
for item in self.fit_plot.plotItem.items[::-1]:
for item in self.fit_plot.items[::-1]:
if item not in [self.data_graph, self.data_graph_imag, self.fit_graph, self.fit_graph_imag]:
self.fit_plot.removeItem(item)

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>864</width>
<height>712</height>
<width>969</width>
<height>974</height>
</rect>
</property>
<property name="windowTitle">
@ -307,17 +307,7 @@
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="PlotWidget" name="fit_plot"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Residuals</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="PlotWidget" name="resid_plot"/>
<widget class="GraphicsLayoutWidget" name="graphicsView"/>
</item>
</layout>
</widget>
@ -435,7 +425,7 @@
<header>..lib.forms</header>
</customwidget>
<customwidget>
<class>PlotWidget</class>
<class>GraphicsLayoutWidget</class>
<extends>QGraphicsView</extends>
<header>pyqtgraph</header>
</customwidget>