Try: plotWidget.setBackgroundBrush(QBrush(Qt.transparent, Qt.NoBrush))
There may be some other code needed as well, but that’s at least part of it. you *may* need to do the same for the view box. So you had the right idea, but perhaps not quite right? --- Israel Brewster Software Engineer Alaska Volcano Observatory Geophysical Institute - UAF 2156 Koyukuk Drive Fairbanks AK 99775-7320 Work: 907-474-5172 cell: 907-328-9145 > On Apr 11, 2020, at 8:11 AM, Daniele Dolci <[email protected]> wrote: > > Hi! > > I have a main widget with a layout and a gradient as background. I want to > add a series of plots with transperent background (basically I would like to > only draw the foreground). I am having hardtimes making the background of the > plot transperent. I tried lot of things, with this code I was expecting that > I would be making all transparent, but it is actually white: > > x = [x for x in range(1000)] > y = [x for x in range(1000)] > plotWidget = pg.PlotWidget(title="Ph") > plotWidget.setBackground((0, 0, 0, 0)) > plotWidget.getViewBox().setBackgroundColor((0, 0, 0, 0)) > self._tab_layout.addWidget(plotWidget, 0, 0) > pen = pg.mkPen(color=(255, 0, 0)) > t = plotWidget.plot(x, y, pen=pen) > t.getViewBox().setBackgroundColor((0, 0, 0, 0)) > > So it looks like this, and I would: > > <plot1.jpg> > > > And I would like to have it drawn on this background instead: > <plot2.jpg> > > > > Any idea how to fix this? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "pyqtgraph" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/pyqtgraph/2e9b649e-dc5e-4a92-ad3f-b6b9cfb6226d%40googlegroups.com > > <https://groups.google.com/d/msgid/pyqtgraph/2e9b649e-dc5e-4a92-ad3f-b6b9cfb6226d%40googlegroups.com?utm_medium=email&utm_source=footer>. > <plot1.jpg><plot2.jpg> -- You received this message because you are subscribed to the Google Groups "pyqtgraph" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/B904541B-89E9-49B1-93B5-1A4C8BF546BE%40alaska.edu.
