Question

How to insert an image from file into a PlotWidget (plt1 = pg.PlotWidget(w);)? The image is for a layout on which some calculated and plotted points should appear.

I tried to insert the image in a Qlabel behind the PlotWidget and make the PlotWidget transparent, but didn't work as transparency takes the color of the window not real transparency.

Thanks

Was it helpful?

Solution

Use QGraphicsPixmapItem:

plt1 = pg.PlotWidget(w)
img = pg.QtGui.QGraphicsPixmapItem(pg.QtGui.QPixmap(fileName))
plt1.addItem(img)

# depending on your preference, you probably want to invert the image:
img.scale(1, -1)

# OR invert the entire view:
plt.invertY(True)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top