pyqtgraph axes not displaying correctly

Viewed 2246

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.

1 Answers

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).

Related