python - PyQt5 QWebView not rendering matplotlib svg properly -


i'm trying use qwebview display html page containing several matplotlib generated svg files. content displays expect, svg figures missing parts. seems though purely horizontal or vertical lines aren't rendered (elements drawn axvline/axhline, grid, errorbar etc.). strangely, resizing window causes missing elements pop view.

what happening here?

example code

from io import bytesio pyqt5 import qtgui, qtwidgets, qtwebkitwidgets matplotlib.figure import figure matplotlib.backends.backend_qt5agg import figurecanvasqtagg figurecanvas import numpy np  # generate figure fig = figure() canvas = figurecanvas(fig) ax = fig.add_subplot(111) x = np.arange(-2*np.pi, 2*np.pi, step=0.1) y = np.sin(x) ax.grid(which='major') ax.plot(x, y) ax.axhline(0, color='black', linestyle='--') ax.axvline(0, color='black', linestyle='--')  # save svg svg = bytesio() fig.savefig(svg, format='svg')  # display in gui app = qtwidgets.qapplication([]) win = qtwidgets.qwidget() win.setwindowtitle('test svg rendering') webview = qtwebkitwidgets.qwebview() webview.setcontent(svg.getvalue()) layout = qtwidgets.qhboxlayout(win) layout.addwidget(canvas) layout.addwidget(webview) win.show() app.exec_() 

output

enter image description here

after resizing window

enter image description here


Comments

Popular posts from this blog

php - Auto increment employee ID -

php - isset function not working properly -

python - Evaluating the next line in a For Loop while in the current iteration -