diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index d7ea5100..3415c3c9 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -148,6 +148,8 @@ class PlotDataItem(GraphicsObject): 'fftMode': False, 'logMode': [False, False], + 'derivativeMode': False, + 'phasemapMode': False, 'alphaHint': 1.0, 'alphaMode': False, @@ -213,7 +215,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 @@ -514,7 +534,13 @@ class PlotDataItem(GraphicsObject): 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) + 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 41011df3..2c6d5d88 100644 --- a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py +++ b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py @@ -253,6 +253,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) @@ -904,6 +906,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 dffc62d0..4862e98b 100644 --- a/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui +++ b/pyqtgraph/graphicsItems/PlotItem/plotConfigTemplate.ui @@ -192,17 +192,17 @@ - 0 - 0 - 154 - 79 + 10 + 10 + 171 + 101 - - + + - Power Spectrum (FFT) + Log Y @@ -213,10 +213,24 @@ - - + + - Log Y + Power Spectrum (FFT) + + + + + + + dV/dT + + + + + + + V vs. V'