Ok, this is interesting. Apparently my minimal reproducible example attempt was a bit *too* minimal. The problem *is* related to the grid being displayed, but *primarily* with a right axis. A left axis can display the grid without significant issue, and master branch does not fix the issue. Actually, to be anal about it, even having the grid on the left axis seems to offset the zoom point by a few pixels at least - it is noticeably different than when there is no grid, in which scenario the zoom point “sticks” to the mouse quite well - but it is nowhere near as noticeable as when using a grid on the right axis.
Doesn’t seem to have helped. I tried with master branch, and the behavior was the same as with previous releases.
Yep, I’ll start working on that. For what it’s worth, it appears to be somewhere between the 0.12.1 release and the 0.12.2 release. Minimal (more or less) code example that illustrates the three options attached. To test, try positioning the mouse cursor directly above a tick mark on the X axis (say, 40), then zoom in using the scroll wheel (or two-finger drag on the trackpad, if you have that configured - that’s what I have). If it behaves the same for you, the top graph (grid on right axis) will have the tick mark shooting off to the right, the middle graph (left axis grid) will have it moving slowly to the left, and the bottom graph (no grid) will more-or-less stay put (*might* have one or two pixel offset, but might just be my cursor positioning). You’ll probably want to make the window a lot bigger first though :-) 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/7A15BABB-946C-4310-AFCB-91CAC3B9E242%40alaska.edu. |
from PySide2.QtWidgets import QApplication, QDialog, QVBoxLayout, QLabel import pyqtgraph as pg
if __name__ == "__main__":
app = QApplication()
dialog = QDialog()
dialog.setWindowTitle("Zoom tests")
layout = QVBoxLayout(dialog)
vals = list(range(100))
# Axis items for first graph
right_axis = pg.AxisItem("right")
right_axis.setGrid(75)
left_axis = pg.AxisItem("left")
# Axis items for second graph
right_axis2 = pg.AxisItem("right")
left_axis2 = pg.AxisItem("left")
left_axis2.setGrid(75)
# axis items for third graph
right_axis3 = pg.AxisItem("right")
left_axis3 = pg.AxisItem("left")
# Grid on right axis, zoom point significantly offset
plotWidget = pg.PlotWidget(dialog,
axisItems={
'right': right_axis,
'left': left_axis,
}
)
plotWidget2 = pg.PlotWidget(dialog,
axisItems = {
'right': right_axis2,
'left': left_axis2,
}
)
plotWidget3 = pg.PlotWidget(dialog,
axisItems = {
'right': right_axis3,
'left': left_axis3,
}
)
plotWidget.plot(vals)
plotWidget2.plot(vals)
plotWidget3.plot(vals)
layout.addWidget(QLabel("Grid on right axis, zoom significantly offset"))
layout.addWidget(plotWidget)
layout.addWidget(QLabel("Grid on left axis, zoom slightly offset (in opposite direction)"))
layout.addWidget(plotWidget2)
layout.addWidget(QLabel("No grid, zoom as expected"))
layout.addWidget(plotWidget3)
dialog.show()
app.exec_()
--- Israel Brewster Software Engineer Alaska Volcano Observatory Geophysical Institute - UAF 2156 Koyukuk Drive Fairbanks AK 99775-7320 Work: 907-474-5172 cell: 907-328-9145
-- 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/7A15BABB-946C-4310-AFCB-91CAC3B9E242%40alaska.edu. |
