Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4be01d0

Browse files
committed
Set widget background to white.
The background color of the widget can be seen by setting a transparent figure facecolor, e.g. from pylab import * rcParams["figure.facecolor"] = (0, 0, 0, 0); gca(); show() The goal is to ultimately replace setting `savefig.transparent` by `figure.facecolor = (0, 0, 0, 0)`. As far as I can tell, gtk3 already defaults to a white background. Not sure what the situation is on OSX.
1 parent 02a5287 commit 4be01d0

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

lib/matplotlib/backends/backend_qt5.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ def __init__(self, figure):
252252
# Key auto-repeat enabled by default
253253
self._keyautorepeat = True
254254

255+
palette = QtGui.QPalette(QtCore.Qt.white)
256+
self.setPalette(palette)
257+
255258
@property
256259
def _dpi_ratio(self):
257260
# Not available on Qt4 or some older Qt5.

lib/matplotlib/backends/backend_tkagg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ def __init__(self, figure, master=None, resize_callback=None):
176176
t1,t2,w,h = self.figure.bbox.bounds
177177
w, h = int(w), int(h)
178178
self._tkcanvas = Tk.Canvas(
179-
master=master, width=w, height=h, borderwidth=0,
180-
highlightthickness=0)
179+
master=master, background="white",
180+
width=w, height=h, borderwidth=0, highlightthickness=0)
181181
self._tkphoto = Tk.PhotoImage(
182182
master=self._tkcanvas, width=w, height=h)
183183
self._tkcanvas.create_image(w//2, h//2, image=self._tkphoto)

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ def do_nothing(*args, **kwargs):
691691
else:
692692
# this does the same in 2.9+
693693
self.SetBackgroundStyle(wx.BG_STYLE_PAINT)
694+
self.SetBackgroundColour(wx.WHITE)
694695

695696
self.macros = {} # dict from wx id to seq of macros
696697

0 commit comments

Comments
 (0)