✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

PyQt5 not displaying plots

I’m using a combination of pyqt5 and plotly to actually display graphs in my application, and until very recently this has worked great. I’ve been loading plotly graphs in as web pages via QWebEngineViews.

After an update on my main development machine, graphs just don’t show up in PyQt5 widgets. On literally every system I have this issue is occurring, the entire list of operating systems I’m able to reproduce this on includes Manjaro, Arch, Ubuntu 18.04 LTS, and Windows 10. The only system of mine this issue isn’t occurring on is a machine that’s a few weeks out of date.

To give an example, this program just displays a blank window, but if you open the plot it produces in a browser that displays fine.

import sys
import plotly
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView

def main():
        A simple example of a plotly application
    # Some data
    x_coords = [1, 2, 3, 5, 6]
    y_coords = [1, 4.5, 7, 24, 38]

    trace = dict(x=x_coords, y=y_coords)

    data = [trace]

    app = QApplication(sys.argv)
    view = QWebEngineView()
    view.load(QUrl(plotly.offline.plot(data, auto_open=False)))
    return app.exec_()

if __name__ == "__main__":

So I’ve tried downgrading libraries, except downgrading ploty, a number of Qt libraries, or even both didn’t resolve the issue. At this point, I’m not really sure what’s wrong, and I’m hoping someone knows how to make plots display in Qt again.

Maybe u can try the code as following

html = '<html><head><meta charset="utf-8" />'
html += '<script src="https://cdn.plot.ly/' \
html += '<body style="width:650px;height:700px;">'
html += plotly.offline.plot(data, auto_open=False)
html += '</body></html>'