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 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/8fd9abd6-6a08-4265-a7df-ad66b2d4ca9dn%40googlegroups.com.