Plot Axis do not intersect and data is off plot.

32 views
Skip to first unread message

Michael Beachy

unread,
Mar 13, 2020, 10:25:27 PM3/13/20
to pyqtgraph
To All,
Thank you for any assistance. I am new to programming.

When I create a simple code, my Plotwidget displays a graph where the data does not match the axis and axis do not even intersect. Nothing I do to the code seems to fix it.

I installed Python 3.8
I just installed PyQt5 following the instructions at the Riverbank site using windows powershell and PIP.

Windows10
Using VSCode.

Anyways, anybody know whats going on and how to fix it. I was having fun with python PyQt5 as it was doing a lot of what I wanted but I noticed when I use the plotwidget() I get this behavior.
Is it better implement MatplotLib instead of plotwidget() and put it into a QWidget? Basically, I would like to build a realtime graph with temperature data. There seems to be a million ways to do this.

//CODE
from PyQt5 import QtWidgets, uic
from pyqtgraph import PlotWidget, plot
import pyqtgraph as pg
import sys  # We need sys so that we can pass argv to QApplication
import os

class MainWindow(QtWidgets.QMainWindow):

    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)

        self.graphWidget = pg.PlotWidget()
        self.setCentralWidget(self.graphWidget)

        hour = [1,2,3,4,5,6,7,8,9,10]
        temperature = [30,32,34,32,33,31,29,32,35,45]

        # plot data: x, y values
        self.graphWidget.plot(hour, temperature)


def main():
    app = QtWidgets.QApplication(sys.argv)
    main = MainWindow()
    main.show()
    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
//Code

Patrick

unread,
Mar 15, 2020, 8:37:07 PM3/15/20
to pyqtgraph
Hi,

Do you happen to have two monitors, with different DPI scaling on each? Or just a hiDPI monitor? I have a feeling someone reported an issue with hiDPI screens before, but the forums are being glitchy at the moment and search isn't working...

Patrick

Michael Beachy

unread,
Mar 16, 2020, 2:03:06 PM3/16/20
to pyqtgraph

Ahh, that seems to be it. I was using my laptop with an external monitor connected by HDMI. It looks like when I go into windows10 multiple displays and click on the different "monitor" numbers, 1 and 2, they both say 1920 x 1080 and both appear to be at that setting.

No matter where Vscode is, when I run the py script and create the plot, it looks distorted in the HDMI connected monitor only. I can drag the plot back and forth using the mouse and can see it distort upon putting it in the 2nd monitor. Its fine if it is on the laptop screen.

Anyways, don't know if this can be noted somewhere for future reference, but it does not sound like a fix is available yet.

Thanks for your help, sincerely appreciated.
Michael Beachy
Reply all
Reply to author
Forward
0 new messages