I tested these signals by taking the working example from before and adding:
```
plot.sigYRangeChanged.connect(lambda : print('hi 1'))
plot.sigXRangeChanged.connect(lambda : print('hi 2'))
plot.sigRangeChanged.connect(lambda : print('hi 3'))
plot.sigTransformChanged.connect(lambda : print('hi 4'))
```The results are: `sigYRangeChanged`: Signals if the user changes the y-axis `sigXRangeChanged`: Signals if the user changes the x-axis `sigRangeChanged`: Signals if the user changes either axis `sigTransformChanged`: I don't know; I did everything to the plot, but this never signaled for me. I see that this signal is emitted in https://github.com/pyqtgraph/pyqtgraph/blob/master/pyqtgraph/widgets/GraphicsView.py when updateMatrix() is called, but I'm not sure when that occurs. Regardless, in looking into this, I was able to find that in https://github.com/pyqtgraph/pyqtgraph/blob/a90c443b7a1291e443fdc24106361294f56ad234/pyqtgraph/graphicsItems/PlotItem/PlotItem.py, there is a plotItem.ctrl.logYCheck signal (thanks also to https://stackoverflow.com/questions/30874243/pyqtgraph-how-track-log-linear-axes-transformation-changes-between-linked-axes). So adding the line: `plot.plotItem.ctrl.logYCheck.toggled.connect(lambda : print('hi5'))` sends a signal when the user toggles that checkbox. So my final code that gets everything working is: ``` from PySide2 import QtGui import pyqtgraph as pg import numpy as np x = np.array([1, 2, 3]) y = np.array([10, 0, 6]) app = QtGui.QApplication([]) plot = pg.PlotWidget() line_ref = plot.plot(x, y) def update_log_plot(): if plot.plotItem.ctrl.logYCheck.isChecked(): line_ref.setData(x[y>0], y[y>0]) else: line_ref.setData(x, y) plot.plotItem.ctrl.logYCheck.toggled.connect(update_log_plot) plot.show() app.exec_() ``` Thanks Patrick! Efrem Braun On Thu, Dec 3, 2020 at 9:05 PM Patrick <[email protected]> wrote: > Hi, > > Not sure the best way to do that, but maybe you could connect to one or > more of the ViewBox signals > <https://pyqtgraph.readthedocs.io/en/latest/_modules/pyqtgraph/graphicsItems/ViewBox/ViewBox.html#ViewBox> > and print some debug output and see if they trigger when you need. They may > not, but might be worth giving a shot. > > sigYRangeChanged = QtCore.Signal(object, object) > sigXRangeChanged = QtCore.Signal(object, object) > sigRangeChangedManually = QtCore.Signal(object) > sigRangeChanged = QtCore.Signal(object, object) > sigStateChanged = QtCore.Signal(object) > sigTransformChanged = QtCore.Signal(object) > sigResized = QtCore.Signal(object) > > Patrick > > On Friday, 4 December 2020 at 11:19:15 am UTC+10:30 [email protected] > wrote: > >> I'd like to allow my software's users to view their data with a log >> scale. However, very often, their data includes 0 values (negative values >> should never occur). When the user >> right-clicks->Plot-Options->Transforms->Log-X, the pen disappears (see the >> minimal working example below, removing the pseudocode lines). >> >> I'd like to put in a simple data filter such that when the user tries to >> put in a transform on the y-axis, I remove the <=0 points from the data >> that should be plotted. How can I attach a signal to the user performing >> right-clicks->Plot-Options->Transforms->Log-X such that I can change the >> data? Should be something like the following, but I don't know what the >> slot would be: >> >> ``` >> from PySide2 import QtGui >> import pyqtgraph as pg >> import numpy as np >> >> x = np.array([1, 2, 3]) >> y = np.array([10, 0, 6]) >> >> app = QtGui.QApplication([]) >> plot = pg.PlotWidget() >> line_ref = plot.plot(x, y) >> >> # begin pseudocode >> plot.logY_Slot.connect(update_log_plot) # What should this be? >> def update_log_plot(): >> if plot.logY: # >> What should this be? >> line_ref.setData(x[y>0], y[y>0]) >> else: >> line_ref.setData(x, y) >> # end pseudocode >> >> plot.show() >> app.exec_() >> ``` >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "pyqtgraph" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/pyqtgraph/pKs_VZ25WOs/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyqtgraph/8fd9abd6-6a08-4265-a7df-ad66b2d4ca9dn%40googlegroups.com > <https://groups.google.com/d/msgid/pyqtgraph/8fd9abd6-6a08-4265-a7df-ad66b2d4ca9dn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CALV7rxkcfU-Tm9SVEzc6gGNbgFcmiJaFJ_TseCqh6m2b4BH3wQ%40mail.gmail.com.
