You can set it by, for example pylab.figure(facecolor=SOME_COLOR, ...)
or matplotlib.rcParams['figure.facecolor'] = SOME_COLOR
. It looks like that its default value is hard-coded, so there is no way to tell MPL to respect GTK theme.
Here's a concrete example of how to do this in PyGTK. Some of this information here was gleaned from "Get colors of current gtk style" and from the gdk.Color docs. I haven't gotten as far as setting the font, etc, but this shows the basic framework you need.
First, define the following function:
def set_graph_appearance(container, figure):
"""
Given a GTK container and a Matplotlib "figure" object, this will set the
figure background colour to be the same as the normal colour of the
container.
"""
# "bg" is the background "style helper" object. It contains five different
# colours, for the five different widget states.
bg_style = container.get_style().bg[gtk.STATE_NORMAL]
gtk_color = (bg_style.red_float, bg_style.green_float, bg_style.blue_float)
figure.set_facecolor(gtk_color)
You can then connect to the realize
signal (maybe also the map-event
signal, I didn't try) and re-colour the graph when the containing widget is created:
graph_panel.connect('realize', set_graph_appearance, graph.figure)
(Here, graph_panel
is a gtk.Alignment
and graph
is a subclass of FigureCanvasGTKAgg
that has a figure
member as needed.)