From 3c832377fb4c4b32fcbdbc60fdfedb57296bc8c0 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Sun, 31 Jan 2021 18:54:43 +0100 Subject: [PATCH] Set the GTK background color to white. This is consistent with the other backends (although this seems to be broken on wx too), which allows semi-transparent figures to be rendered against a consistent background (this can be checked e.g. with `figure(facecolor=(0, 0, 0, 0))` or `figure(facecolor=(1, 1, 1, .5))`), which would previously be rendered differently on gtk3 when using a dark theme. --- lib/matplotlib/backends/backend_gtk3.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index 68e43ca2b32b..86fd208e1226 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -127,6 +127,12 @@ def __init__(self, figure=None): self.set_can_focus(True) + css = Gtk.CssProvider() + css.load_from_data(b".matplotlib-canvas { background-color: white; }") + style_ctx = self.get_style_context() + style_ctx.add_provider(css, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + style_ctx.add_class("matplotlib-canvas") + renderer_init = _api.deprecate_method_override( __class__._renderer_init, self, allow_empty=True, since="3.3", addendum="Please initialize the renderer, if needed, in the " pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy