Skip to content

showGrid with showAxis('right', ...) causes displacement between mouse mode selection area and mouse cursor position #1937

@swvanbuuren

Description

@swvanbuuren

Short description

For a plot with x- and y-grid lines as well as the right axis enabled, the selection area's bottom right corner (created for mouse interaction mode set to RectMode) is (stronlgy) displaced from the mouse cursor position.

Code to reproduce

import pyqtgraph as pg
from pyqtgraph.Qt import QtGui
import numpy as np

win = pg.GraphicsLayoutWidget(show=True)
win.resize(800,350)
win.setWindowTitle('pyqtgraph example: Histogram')
plt1 = win.addPlot()
plt2 = win.addPlot()

# preset mouse mode to 1 button for quick testing
plt1.getViewBox().setMouseMode(pg.ViewBox.RectMode)
plt2.getViewBox().setMouseMode(pg.ViewBox.RectMode)

# create data
x = np.arange(100)
y = np.random.normal(size=100)

plt1.plot(x, y)
plt2.plot(x, y)

plt1.showAxis('right', show=True)
plt2.showAxis('right', show=True)

plt1.showGrid(x=False, y=False)
plt2.showGrid(x=True, y=True)

QtGui.QApplication.instance().exec_()

Expected behavior

The bottom right corner of the selection area coincides with the mouse cursor position.
20210731_bug_expected

Real behavior

The bottom right corner of the selection area is (strongly) displaced from the mouse cursor position.
20210731_bug_actual

Tested environment(s)

  • PyQtGraph version: 0.12.2
  • Qt Python binding: PySide2 5.15.1 Qt 5.15.1
  • Python version: 3.8.10
  • NumPy version: 1.19.2
  • Operating system: XUbuntu 20.04.2 LTS
  • Installation method: pip

Additional context

The displacement magnitude and direction between selection area and mouse cursor seems to depend on the activation of the x- and y- grid lines as well as the plot's right axis. For example, only activating x-grid lines leads to a strong displacement in vertical direction (contrary to the example above, where the displacement is in horizontal direction).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions