forked from IPKM/nmreval
weird bug for log-scaling fixed; fixes T248
This commit is contained in:
parent
b1e54c8432
commit
bf437ef8a7
@ -25,6 +25,9 @@ class QShift(QtWidgets.QDialog, Ui_shift_dialog):
|
||||
self.data = {}
|
||||
self._colors = cycle(Tab10)
|
||||
|
||||
self.graphicsView.plotItem.ctrl.logXCheck.blockSignals(True)
|
||||
self.graphicsView.plotItem.ctrl.logYCheck.blockSignals(True)
|
||||
|
||||
delegate = SpinBoxDelegate()
|
||||
delegate.valueChanged.connect(self.shift)
|
||||
self.shift_table.setItemDelegate(delegate)
|
||||
@ -40,10 +43,10 @@ class QShift(QtWidgets.QDialog, Ui_shift_dialog):
|
||||
def add_item(self, idx, name, x, y):
|
||||
color = mkColor(next(self._colors).rgb())
|
||||
if np.iscomplexobj(y):
|
||||
pl = [PlotItem(x, y.real, name=name, pen=mkPen(color=color)),
|
||||
PlotItem(x, y.imag, name=name, pen=mkPen(color=color))]
|
||||
pl = [PlotItem(x=x, y=y.real, name=name, pen=mkPen(color=color)),
|
||||
PlotItem(x=x, y=y.imag, name=name, pen=mkPen(color=color))]
|
||||
else:
|
||||
pl = [PlotItem(x, y, name=name, pen=mkPen(color=color))]
|
||||
pl = [PlotItem(x=x, y=y, name=name, symbol='t', pen=mkPen(color=color))]
|
||||
|
||||
self.data[idx] = (pl, x, y)
|
||||
|
||||
@ -123,10 +126,18 @@ class QShift(QtWidgets.QDialog, Ui_shift_dialog):
|
||||
def set_log(self, state: int):
|
||||
if self.sender() == self.xlog_checkbox:
|
||||
log_state = self.graphicsView.plotItem.ctrl.logXCheck
|
||||
func = self.graphicsView.setXRange
|
||||
else:
|
||||
log_state = self.graphicsView.plotItem.ctrl.logYCheck
|
||||
func = self.graphicsView.setYRange
|
||||
|
||||
log_state.setCheckState(state)
|
||||
self.graphicsView.plotItem.updateLogMode()
|
||||
# For some combinations of Python, pyqt, and pyqtgraph, updateLogMode does not update
|
||||
# view range to log values and logTickValues generates LOTS of ticks, which freezes everything.
|
||||
# -> Call setRange to interrupt the loop.
|
||||
func(0, 1)
|
||||
self.graphicsView.enableAutoRange()
|
||||
|
||||
def on_overwrite_checkbox_stateChanged(self, state: int):
|
||||
self.data_newgraph.setVisible(state != QtCore.Qt.Checked)
|
||||
|
@ -419,7 +419,7 @@ class QGraphWindow(QtWidgets.QGraphicsView, Ui_GraphWindow):
|
||||
|
||||
self.plotItem.updateLogMode()
|
||||
|
||||
self.set_range(x=r[0], y=r[1])
|
||||
self.plotItem.enableAutoRange()
|
||||
|
||||
def enable_picking(self, enabled: bool):
|
||||
if enabled:
|
||||
|
@ -179,8 +179,12 @@ class PlotItem(PlotDataItem):
|
||||
self.opts['linecolor'] = c.red(), c.green(), c.blue()
|
||||
|
||||
if self.symbol != SymbolStyle.No:
|
||||
c = self.opts['symbolBrush'].color()
|
||||
self.opts['symbolcolor'] = c.red(), c.green(), c.blue()
|
||||
brush = self.opts['symbolBrush']
|
||||
if isinstance(brush, tuple):
|
||||
self.opts['symbolcolor'] = brush
|
||||
else:
|
||||
c = brush.color()
|
||||
self.opts['symbolcolor'] = c.red(), c.green(), c.blue()
|
||||
|
||||
def __getitem__(self, item):
|
||||
return self.opts.get(item, None)
|
||||
@ -229,7 +233,7 @@ class PlotItem(PlotDataItem):
|
||||
else:
|
||||
return lc
|
||||
|
||||
def updateItems(self):
|
||||
def updateItems(self, styleUpdate=True):
|
||||
"""
|
||||
We override this function so that curves with nan/inf values can be displayed.
|
||||
Newer versions close this bug differently (https://github.com/pyqtgraph/pyqtgraph/pull/1058)
|
||||
@ -261,6 +265,7 @@ class PlotItem(PlotDataItem):
|
||||
# remove all bad values
|
||||
x = x[is_finite]
|
||||
y = y[is_finite]
|
||||
curveArgs['connect'] = 'all'
|
||||
self.curve.setData(x=x, y=y, **curveArgs)
|
||||
self.curve.show()
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user