Merge pull request #467 from meganbkratz/derivativePlots_cleanup

Add dy/dx and y vs. y` plot modes to context menus from plots.
This commit is contained in:
Ogi Moore 2020-06-27 12:50:44 -07:00 committed by GitHub
commit a719a06b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 160 additions and 50 deletions

View File

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

View File

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

View File

@ -192,17 +192,23 @@
<widget class="QFrame" name="transformGroup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>154</width>
<height>79</height>
<x>10</x>
<y>10</y>
<width>171</width>
<height>101</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="fftCheck">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="2" column="0">
<widget class="QCheckBox" name="logYCheck">
<property name="text">
<string>Power Spectrum (FFT)</string>
<string>Log Y</string>
</property>
</widget>
</item>
@ -213,10 +219,24 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="logYCheck">
<item row="0" column="0">
<widget class="QCheckBox" name="fftCheck">
<property name="text">
<string>Log Y</string>
<string>Power Spectrum (FFT)</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="derivativeCheck">
<property name="text">
<string>dy/dx</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QCheckBox" name="phasemapCheck">
<property name="text">
<string>Y vs. Y'</string>
</property>
</widget>
</item>

View File

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

View File

@ -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"))

View File

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

View File

@ -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"))