8

I recently started working with PyQt5 after updating pyqt from PyQt4 to PyQt5, and have noticed a persistent error in the axis location of all plots produced with pyqtgraph (see attached figure). The x axis does not stretch across the bottom of the window, and the y axis is not joined to the x axis in the lower left corner. Furthermore, the trace is not accurately represented by the axis labels at large x values or small y values.

The figure below was produced by running:

import pyqtgraph as pg
pg.plot([0,1,2,3,4,5,6,7,8,9],[1,2,4,5,7,8,10,11,13,14])

pyqtgraph output

I've created a new python environment using anaconda on my Windows 10 machine to test this problem. The output of conda list qt is:

pyqt                      5.6.0                    py35_2
pyqtgraph                 0.10.0                   py35_0
qt                        5.6.2                    vc14_5  [vc14]

I've attempted working with different versions of Python (3.5.3 and 3.6) and removing and reinstalling all anaconda distributions without success. I would really appreciate any help with this issue. Thanks in advance.

Edit 1: I should have mentioned that I was running this program on an external monitor. I just discovered that if I drag the plotting window to my smaller laptop display, the axes snap into their correct position. I have still not discovered how to display the plot properly on my external monitor, but I suspect it may have something to do with the QT DPI scaling environment variables.

apogalacticon
  • 709
  • 1
  • 9
  • 19
  • 1
    Got the same problem here with a specific desktop configuration: If I have desktop scale on my main monitor, e.g. 125%, on which I launch my application, and then no scale on a secondary monitor, on which I show the graph window, the graph plotting will be off. The problem goes away if I remove the desktop scale, set both monitors to use same scale, or move the graph window to the main monitor. Not sure how desktop scale is actually applied, but seems like pyqtgraph, or some api it uses, incorrectly assumes same scale on secondary monitors. – shadow_map Dec 11 '20 at 01:44

1 Answers1

5

I have found two possible solutions to this issue:

1) The following line may be added after the Qt GUI event loop begins to set the DPI app.setAttribute(QtCore.Qt.AA_Use96Dpi)

2) The Windows settings display scaling parameters for the external monitor must match the display scaling value for the primary display (a laptop display, in my case).

apogalacticon
  • 709
  • 1
  • 9
  • 19
  • 1
    this actually broke the axis on my first monitor... I wonder if someone has another possible solution for this multiple monitors problem – Luiz Tauffer Jul 02 '20 at 10:46