How to change background color of the PlotWidget in a JupyterNotebook

80 views
Skip to first unread message

片山 大輝

unread,
Mar 11, 2023, 11:20:27 AM3/11/23
to pyqt...@googlegroups.com
Hi, 

I want to change the graph style in a jupyter notebook.
(e.g. the background color of the PlotWidget from pyqtgraph.jupyter)

I tried, but the "setBackground" function does not exist.
Could you please tell me how to do this?

> import pyqtgraph as pg
> from pyqtgraph.jupyter import PlotWidget

> pg.mkQApp()
> pw = PlotWidget()
> pw.plot(x=[1,2,3], y=[1,3,2])
> pw.setBackground("#FFFFFF00") # AttributeError occured
> pw  

Thank you in advance for your help.

--
KATAYAMA Daiki

Shin-ichiro Tanaka

unread,
Mar 12, 2023, 9:35:08 PM3/12/23
to pyqt...@googlegroups.com
Hi,

I experienced the same issue in my system.

Instead, how about using

"pg.setConfigOption('background', 'w')
pg.setConfigOption('foreground', 'k’)"
.

These should be placed before “pw=PlotWidget()”.



> 2023/03/12 1:20、片山 大輝 <kappa12...@gmail.com>のメール:
> --
> 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 pyqtgraph+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CAJekVOWN_LCxW%2BpvV88JP1sgcrAkjqcCk1Z%3D72LaRs39eS9X3A%40mail.gmail.com.

片山 大輝

unread,
Mar 13, 2023, 11:17:17 AM3/13/23
to pyqt...@googlegroups.com
Tanaka-san

I appreciate your response to my issue. Your answer was very helpful and it was able to solve my problem.
Thank you again for your support.

2023年3月13日(月) 10:35 Shin-ichiro Tanaka <tanaka.shi...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages