So I tried this:

x = [x for x in range(1000)]
y = [x for x in range(1000)]
plotWidget = pg.PlotWidget(title="Ph")
plotWidget.setBackgroundBrush(QtGui.QBrush(QtCore.Qt.transparent, 
QtCore.Qt.NoBrush))
self._tab_layout.addWidget(plotWidget, 0, 0)
t = plotWidget.plot(x, y)


But the background is still white. I removed all the viewBox stuff and the 
set colors. I mean, this is very weird. If the plot accepts colors for pen 
and background in the format of RGBa, why wouldn't the transperency do the 
trick?

I have also tried using just plotItem, without the widget, but I wasn't 
able to add it to the layout so I couldn't really finish the test. 

Thanks for your time man, I appreciate!
Cheers,

Il giorno sabato 11 aprile 2020 19:42:31 UTC+2, Israel Brewster ha scritto:
>
> No, I mis-spoke with that. I took another look at my code, and realized 
> that I’m not doing *anything* with the view box. So try just doing the 
> setBackgroudBrush on the plotWidget, but *don’t* set the background color 
> on the view box at all. If that doesn’t work, then I’m probably missing 
> something somewhere else in my code that does it…
>
> ---
> 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:37 AM, Daniele Dolci <[email protected] 
> <javascript:>> wrote:
>
> Thanks for the fast reply! 
>
> I tried to add that line but didn't work. I then tried to apply it to the 
> plot item and to the view box, but on both I get the error:
>
> plotWidget.getViewBox().setBackgroundBrush(QtGui.QBrush(QtCore.Qt.transparent,
>  
> QtCore.Qt.NoBrush))
> AttributeError: 'ViewBox' object has no attribute 'setBackgroundBrush'
>
> Maybe I misunderstood what you meant by doing the same for the ViewBox?
>
> Thanks again! 
>
>
> Il giorno sabato 11 aprile 2020 18:20:06 UTC+2, Israel Brewster ha scritto:
>>
>> 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].
>> 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] <javascript:>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pyqtgraph/3c60ca81-99f3-4c4c-9a4e-7cd22d7f9335%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/pyqtgraph/3c60ca81-99f3-4c4c-9a4e-7cd22d7f9335%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
>
>

-- 
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/4c71a8d2-5d8c-41a7-a3d2-e5a9dc106117%40googlegroups.com.

Reply via email to