Possible to use SVG as background?

37 views
Skip to first unread message

Israel Brewster

unread,
Jun 13, 2019, 4:18:24 PM6/13/19
to pyqtgraph
I was wondering if there was any way to use a SVG image as a background in pyqtgraph? I’m using pyqtgraph for an interactive mapping application, and using PNG’s I have to make a choice between slow loading and high memory usage, but good resolution when zooming in, vs quick loading and low memory usage, but pixelated images when zooming in. Since my “maps” are just coastlines, it seems like this would be an ideal use of the scalability of an SVG (assuming I can come up with an appropriate SVG, of course)

---
Israel Brewster
Software Engineer
Alaska Volcano Observatory 
Geophysical Institute - UAF 
2156 Koyukuk Drive 
Fairbanks AK 99775-7320

Israel Brewster

unread,
Aug 9, 2019, 3:46:03 PM8/9/19
to pyqtgraph
To answer my own question, in case someone else has the same one: it is actually quite easy to use a svg as a background image: you can simply load the svg into a QGraphicsSVGItem and then use it in the same way you would a pg.ImageItem. Some of the interfaces (such as for setting the size/position) are slightly different, but the PlotItem addItem() function will happily accept the QGraphicsSVGItem and draw it properly! End result is much lower memory usage (by about 2GB over the high-resolution images I was using), and a background image that looks good at ANY zoom level.
Reply all
Reply to author
Forward
0 new messages