diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index 58a218c7..7256f721 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -155,6 +155,8 @@ class PlotDataItem(GraphicsObject): 'fftMode': False, 'logMode': [False, False], + 'derivativeMode': False, + 'phasemapMode': False, 'alphaHint': 1.0, 'alphaMode': False, @@ -221,7 +223,25 @@ class PlotDataItem(GraphicsObject): self.xClean = self.yClean = None self.updateItems() self.informViewBoundsChanged() - + + def setDerivativeMode(self, mode): + if self.opts['derivativeMode'] == mode: + return + self.opts['derivativeMode'] = mode + self.xDisp = self.yDisp = None + self.xClean = self.yClean = None + self.updateItems() + self.informViewBoundsChanged() + + def setPhasemapMode(self, mode): + if self.opts['phasemapMode'] == mode: + return + self.opts['phasemapMode'] = mode + self.xDisp = self.yDisp = None + self.xClean = self.yClean = None + self.updateItems() + self.informViewBoundsChanged() + def setPointMode(self, mode): if self.opts['pointMode'] == mode: return @@ -523,13 +543,24 @@ class PlotDataItem(GraphicsObject): if self.opts['logMode'][0]: x=x[1:] y=y[1:] + else: + if self.opts['logMode'][0]: + x = np.log10(x) + if self.opts['logMode'][1]: + y = np.log10(y) + if self.opts['derivativeMode']: # plot dV/dt + y = np.diff(self.yData)/np.diff(self.xData) + x = x[:-1] + if self.opts['phasemapMode']: # plot dV/dt vs V + x = self.yData[:-1] + y = np.diff(self.yData)/np.diff(self.xData) with np.errstate(divide='ignore'): if self.opts['logMode'][0]: x = np.log10(x) if self.opts['logMode'][1]: y = np.log10(y) - + ds = self.opts['downsample'] if not isinstance(ds, int): ds = 1 diff --git a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py index 38a9ba5c..0b91daaa 100644 --- a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py +++ b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py @@ -230,6 +230,8 @@ class PlotItem(GraphicsWidget): c.fftCheck.toggled.connect(self.updateSpectrumMode) c.logXCheck.toggled.connect(self.updateLogMode) c.logYCheck.toggled.connect(self.updateLogMode) + c.derivativeCheck.toggled.connect(self.updateDerivativeMode) + c.phasemapCheck.toggled.connect(self.updatePhasemapMode) c.downsampleSpin.valueChanged.connect(self.updateDownsampling) c.downsampleCheck.toggled.connect(self.updateDownsampling) @@ -898,6 +900,23 @@ class PlotItem(GraphicsWidget): self.getAxis('right').setLogMode(y) self.enableAutoRange() self.recomputeAverages() + + def updateDerivativeMode(self): + d = self.ctrl.derivativeCheck.isChecked() + for i in self.items: + if hasattr(i, 'setDerivativeMode'): + i.setDerivativeMode(d) + self.enableAutoRange() + self.recomputeAverages() + + def updatePhasemapMode(self): + d = self.ctrl.phasemapCheck.isChecked() + for i in self.items: + if hasattr(i, 'setPhasemapMode'): + i.setPhasemapMode(d) + self.enableAutoRange() + self.recomputeAverages() + def setDownsampling(self, ds=None, auto=None, mode=None): """Change the default downsampling mode for all PlotDataItems managed by this plot. diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui index 12d8033e..e718d1d5 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui @@ -192,17 +192,23 @@ - 0 - 0 - 154 - 79 + 10 + 10 + 171 + 101 - - + + 0 + + + 0 + + + - Power Spectrum (FFT) + Log Y @@ -213,10 +219,24 @@ - - + + - Log Y + Power Spectrum (FFT) + + + + + + + dy/dx + + + + + + + Y vs. Y' diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py index 5ecc0438..2b752c4d 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file './pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui' +# Form implementation generated from reading ui file 'pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui' # -# Created: Mon Dec 23 10:10:51 2013 -# by: PyQt4 UI code generator 4.10 +# Created: Fri Mar 31 10:35:34 2017 +# by: PyQt4 UI code generator 4.11.3 # # WARNING! All changes made in this file will be lost! @@ -84,19 +84,27 @@ class Ui_Form(object): self.downsampleSpin.setObjectName(_fromUtf8("downsampleSpin")) self.gridLayout_4.addWidget(self.downsampleSpin, 1, 1, 1, 1) self.transformGroup = QtGui.QFrame(Form) - self.transformGroup.setGeometry(QtCore.QRect(0, 0, 154, 79)) + self.transformGroup.setGeometry(QtCore.QRect(10, 10, 171, 101)) self.transformGroup.setObjectName(_fromUtf8("transformGroup")) self.gridLayout = QtGui.QGridLayout(self.transformGroup) + self.gridLayout.setMargin(0) + self.gridLayout.setSpacing(0) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.fftCheck = QtGui.QCheckBox(self.transformGroup) - self.fftCheck.setObjectName(_fromUtf8("fftCheck")) - self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) - self.logXCheck = QtGui.QCheckBox(self.transformGroup) - self.logXCheck.setObjectName(_fromUtf8("logXCheck")) - self.gridLayout.addWidget(self.logXCheck, 1, 0, 1, 1) self.logYCheck = QtGui.QCheckBox(self.transformGroup) self.logYCheck.setObjectName(_fromUtf8("logYCheck")) self.gridLayout.addWidget(self.logYCheck, 2, 0, 1, 1) + self.logXCheck = QtGui.QCheckBox(self.transformGroup) + self.logXCheck.setObjectName(_fromUtf8("logXCheck")) + self.gridLayout.addWidget(self.logXCheck, 1, 0, 1, 1) + self.fftCheck = QtGui.QCheckBox(self.transformGroup) + self.fftCheck.setObjectName(_fromUtf8("fftCheck")) + self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) + self.derivativeCheck = QtGui.QCheckBox(self.transformGroup) + self.derivativeCheck.setObjectName(_fromUtf8("derivativeCheck")) + self.gridLayout.addWidget(self.derivativeCheck, 3, 0, 1, 1) + self.phasemapCheck = QtGui.QCheckBox(self.transformGroup) + self.phasemapCheck.setObjectName(_fromUtf8("phasemapCheck")) + self.gridLayout.addWidget(self.phasemapCheck, 4, 0, 1, 1) self.pointsGroup = QtGui.QGroupBox(Form) self.pointsGroup.setGeometry(QtCore.QRect(10, 550, 234, 58)) self.pointsGroup.setCheckable(True) @@ -169,9 +177,11 @@ class Ui_Form(object): self.autoDownsampleCheck.setText(_translate("Form", "Auto", None)) self.downsampleSpin.setToolTip(_translate("Form", "Downsample data before plotting. (plot every Nth sample)", None)) self.downsampleSpin.setSuffix(_translate("Form", "x", None)) - self.fftCheck.setText(_translate("Form", "Power Spectrum (FFT)", None)) - self.logXCheck.setText(_translate("Form", "Log X", None)) self.logYCheck.setText(_translate("Form", "Log Y", None)) + self.logXCheck.setText(_translate("Form", "Log X", None)) + self.fftCheck.setText(_translate("Form", "Power Spectrum (FFT)", None)) + self.derivativeCheck.setText(_translate("Form", "dy/dx", None)) + self.phasemapCheck.setText(_translate("Form", "Y vs. Y\'", None)) self.pointsGroup.setTitle(_translate("Form", "Points", None)) self.autoPointsCheck.setText(_translate("Form", "Auto", None)) self.xGridCheck.setText(_translate("Form", "Show X Grid", None)) diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py index 817221f2..96eaea70 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyqt5.py @@ -70,16 +70,24 @@ class Ui_Form(object): self.downsampleSpin.setObjectName("downsampleSpin") self.gridLayout_4.addWidget(self.downsampleSpin, 1, 1, 1, 1) self.transformGroup = QtWidgets.QFrame(Form) - self.transformGroup.setGeometry(QtCore.QRect(0, 0, 154, 79)) + self.transformGroup.setGeometry(QtCore.QRect(10, 10, 171, 101)) self.transformGroup.setObjectName("transformGroup") self.gridLayout = QtWidgets.QGridLayout(self.transformGroup) self.gridLayout.setObjectName("gridLayout") - self.fftCheck = QtWidgets.QCheckBox(self.transformGroup) - self.fftCheck.setObjectName("fftCheck") - self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) - self.logXCheck = QtWidgets.QCheckBox(self.transformGroup) + self.gridLayout.setMargin(0) + self.gridLayout.setSpacing(0) + self.logXCheck = QtGui.QCheckBox(self.transformGroup) self.logXCheck.setObjectName("logXCheck") self.gridLayout.addWidget(self.logXCheck, 1, 0, 1, 1) + self.fftCheck = QtGui.QCheckBox(self.transformGroup) + self.fftCheck.setObjectName("fftCheck") + self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) + self.derivativeCheck = QtGui.QCheckBox(self.transformGroup) + self.derivativeCheck.setObjectName("derivativeCheck") + self.gridLayout.addWidget(self.derivativeCheck, 3, 0, 1, 1) + self.phasemapCheck = QtGui.QCheckBox(self.transformGroup) + self.phasemapCheck.setObjectName("phasemapCheck") + self.gridLayout.addWidget(self.phasemapCheck, 4, 0, 1, 1) self.logYCheck = QtWidgets.QCheckBox(self.transformGroup) self.logYCheck.setObjectName("logYCheck") self.gridLayout.addWidget(self.logYCheck, 2, 0, 1, 1) @@ -156,8 +164,10 @@ class Ui_Form(object): self.autoDownsampleCheck.setText(_translate("Form", "Auto")) self.downsampleSpin.setToolTip(_translate("Form", "Downsample data before plotting. (plot every Nth sample)")) self.downsampleSpin.setSuffix(_translate("Form", "x")) - self.fftCheck.setText(_translate("Form", "Power Spectrum (FFT)")) - self.logXCheck.setText(_translate("Form", "Log X")) + self.logXCheck.setText(_translate("Form", "Log X", None)) + self.fftCheck.setText(_translate("Form", "Power Spectrum (FFT)", None)) + self.derivativeCheck.setText(_translate("Form", "dy/dx", None)) + self.phasemapCheck.setText(_translate("Form", "Y vs. Y\'", None)) self.logYCheck.setText(_translate("Form", "Log Y")) self.pointsGroup.setTitle(_translate("Form", "Points")) self.autoPointsCheck.setText(_translate("Form", "Auto")) diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside.py b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside.py index d0fd1edd..9c999b89 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside.py +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file './pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui' +# Form implementation generated from reading ui file 'plotConfigTemplate.ui' # -# Created: Mon Dec 23 10:10:52 2013 -# by: pyside-uic 0.2.14 running on PySide 1.1.2 +# Created: Fri Jun 26 23:50:06 2020 +# by: pyside-uic 0.2.15 running on PySide 1.2.4 # # WARNING! All changes made in this file will be lost! @@ -70,19 +70,27 @@ class Ui_Form(object): self.downsampleSpin.setObjectName("downsampleSpin") self.gridLayout_4.addWidget(self.downsampleSpin, 1, 1, 1, 1) self.transformGroup = QtGui.QFrame(Form) - self.transformGroup.setGeometry(QtCore.QRect(0, 0, 154, 79)) + self.transformGroup.setGeometry(QtCore.QRect(10, 10, 171, 101)) self.transformGroup.setObjectName("transformGroup") self.gridLayout = QtGui.QGridLayout(self.transformGroup) + self.gridLayout.setContentsMargins(0, 0, 0, 0) + self.gridLayout.setSpacing(0) self.gridLayout.setObjectName("gridLayout") - self.fftCheck = QtGui.QCheckBox(self.transformGroup) - self.fftCheck.setObjectName("fftCheck") - self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) - self.logXCheck = QtGui.QCheckBox(self.transformGroup) - self.logXCheck.setObjectName("logXCheck") - self.gridLayout.addWidget(self.logXCheck, 1, 0, 1, 1) self.logYCheck = QtGui.QCheckBox(self.transformGroup) self.logYCheck.setObjectName("logYCheck") self.gridLayout.addWidget(self.logYCheck, 2, 0, 1, 1) + self.logXCheck = QtGui.QCheckBox(self.transformGroup) + self.logXCheck.setObjectName("logXCheck") + self.gridLayout.addWidget(self.logXCheck, 1, 0, 1, 1) + self.fftCheck = QtGui.QCheckBox(self.transformGroup) + self.fftCheck.setObjectName("fftCheck") + self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) + self.derivativeCheck = QtGui.QCheckBox(self.transformGroup) + self.derivativeCheck.setObjectName("derivativeCheck") + self.gridLayout.addWidget(self.derivativeCheck, 3, 0, 1, 1) + self.phasemapCheck = QtGui.QCheckBox(self.transformGroup) + self.phasemapCheck.setObjectName("phasemapCheck") + self.gridLayout.addWidget(self.phasemapCheck, 4, 0, 1, 1) self.pointsGroup = QtGui.QGroupBox(Form) self.pointsGroup.setGeometry(QtCore.QRect(10, 550, 234, 58)) self.pointsGroup.setCheckable(True) @@ -155,9 +163,11 @@ class Ui_Form(object): self.autoDownsampleCheck.setText(QtGui.QApplication.translate("Form", "Auto", None, QtGui.QApplication.UnicodeUTF8)) self.downsampleSpin.setToolTip(QtGui.QApplication.translate("Form", "Downsample data before plotting. (plot every Nth sample)", None, QtGui.QApplication.UnicodeUTF8)) self.downsampleSpin.setSuffix(QtGui.QApplication.translate("Form", "x", None, QtGui.QApplication.UnicodeUTF8)) - self.fftCheck.setText(QtGui.QApplication.translate("Form", "Power Spectrum (FFT)", None, QtGui.QApplication.UnicodeUTF8)) - self.logXCheck.setText(QtGui.QApplication.translate("Form", "Log X", None, QtGui.QApplication.UnicodeUTF8)) self.logYCheck.setText(QtGui.QApplication.translate("Form", "Log Y", None, QtGui.QApplication.UnicodeUTF8)) + self.logXCheck.setText(QtGui.QApplication.translate("Form", "Log X", None, QtGui.QApplication.UnicodeUTF8)) + self.fftCheck.setText(QtGui.QApplication.translate("Form", "Power Spectrum (FFT)", None, QtGui.QApplication.UnicodeUTF8)) + self.derivativeCheck.setText(QtGui.QApplication.translate("Form", "dy/dx", None, QtGui.QApplication.UnicodeUTF8)) + self.phasemapCheck.setText(QtGui.QApplication.translate("Form", "Y vs. Y\'", None, QtGui.QApplication.UnicodeUTF8)) self.pointsGroup.setTitle(QtGui.QApplication.translate("Form", "Points", None, QtGui.QApplication.UnicodeUTF8)) self.autoPointsCheck.setText(QtGui.QApplication.translate("Form", "Auto", None, QtGui.QApplication.UnicodeUTF8)) self.xGridCheck.setText(QtGui.QApplication.translate("Form", "Show X Grid", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside2.py b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside2.py index d801f298..34b4911e 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside2.py +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate_pyside2.py @@ -70,16 +70,24 @@ class Ui_Form(object): self.downsampleSpin.setObjectName("downsampleSpin") self.gridLayout_4.addWidget(self.downsampleSpin, 1, 1, 1, 1) self.transformGroup = QtWidgets.QFrame(Form) - self.transformGroup.setGeometry(QtCore.QRect(0, 0, 154, 79)) + self.transformGroup.setGeometry(QtCore.QRect(10, 10, 171, 101)) self.transformGroup.setObjectName("transformGroup") self.gridLayout = QtWidgets.QGridLayout(self.transformGroup) + self.gridLayout.setMargin(0) + self.gridLayout.setSpacing(0) self.gridLayout.setObjectName("gridLayout") - self.fftCheck = QtWidgets.QCheckBox(self.transformGroup) - self.fftCheck.setObjectName("fftCheck") - self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) - self.logXCheck = QtWidgets.QCheckBox(self.transformGroup) + self.logXCheck = QtGui.QCheckBox(self.transformGroup) self.logXCheck.setObjectName("logXCheck") self.gridLayout.addWidget(self.logXCheck, 1, 0, 1, 1) + self.fftCheck = QtGui.QCheckBox(self.transformGroup) + self.fftCheck.setObjectName("fftCheck") + self.gridLayout.addWidget(self.fftCheck, 0, 0, 1, 1) + self.derivativeCheck = QtGui.QCheckBox(self.transformGroup) + self.derivativeCheck.setObjectName("derivativeCheck") + self.gridLayout.addWidget(self.derivativeCheck, 3, 0, 1, 1) + self.phasemapCheck = QtGui.QCheckBox(self.transformGroup) + self.phasemapCheck.setObjectName("phasemapCheck") + self.gridLayout.addWidget(self.phasemapCheck, 4, 0, 1, 1) self.logYCheck = QtWidgets.QCheckBox(self.transformGroup) self.logYCheck.setObjectName("logYCheck") self.gridLayout.addWidget(self.logYCheck, 2, 0, 1, 1) @@ -156,8 +164,10 @@ class Ui_Form(object): self.autoDownsampleCheck.setText(_translate("Form", "Auto")) self.downsampleSpin.setToolTip(_translate("Form", "Downsample data before plotting. (plot every Nth sample)")) self.downsampleSpin.setSuffix(_translate("Form", "x")) - self.fftCheck.setText(_translate("Form", "Power Spectrum (FFT)")) - self.logXCheck.setText(_translate("Form", "Log X")) + self.logXCheck.setText(_translate("Form", "Log X", None)) + self.fftCheck.setText(_translate("Form", "Power Spectrum (FFT)", None)) + self.derivativeCheck.setText(_translate("Form", "dy/dx", None)) + self.phasemapCheck.setText(_translate("Form", "Y vs. Y\'", None)) self.logYCheck.setText(_translate("Form", "Log Y")) self.pointsGroup.setTitle(_translate("Form", "Points")) self.autoPointsCheck.setText(_translate("Form", "Auto"))