Exemples de comment changer la couleur de fond d'une figure avec Matplotlib:
Table des matières
Avec subplot et l'option axisbg
from pylab import *subplot(111, axisbg='#ababab')t = arange(0.0, 2.0, 0.01)s = sin(2*pi*t)plot(t, s)xlabel('x')ylabel('y')title('How to change background color in matplotlib ?')savefig('exemple_01.png')show()

source: How to set opacity of background colour of graph wit Matplotlib (stackoverflow)
Avec figure patch.set_facecolor()
On peut aussi indiquer la transparence avec patch.set_alpha()
import matplotlib.pyplot as pltfrom pylab import *fig = plt.figure()fig.patch.set_facecolor('#E0E0E0')fig.patch.set_alpha(0.7)ax = fig.add_subplot(111)t = arange(0.0, 2.0, 0.01)s = sin(2*pi*t)plot(t, s)ax.plot(t, s) #plot(range(10))ax.patch.set_facecolor('#ababab')ax.patch.set_alpha(0.5)# If we don't specify the edgecolor and facecolor for the figure when# saving with savefig, it will override the value we set earlier!fig.savefig('exemple_02.png', facecolor=fig.get_facecolor(), edgecolor='none')plt.show()

Références
| Liens | Site |
|---|---|
| How to change plot background color? | stackoverflow |
| color example code | matplotlib |
| color_demo | matplotlib docs |
| how-to-change-the-face-color-of-a-plot-using-matplotlib | How to change the face color of a plot using Matplotlib (stackoverflow) |
| python-changing-plot-background-color-in-matplotlib | Python - changing plot background color in matplotlib (stackoverflow) |
| how-to-set-opacity-of-background-colour-of-graph-wit-matplotlib | How to set opacity of background colour of graph wit Matplotlib (stackoverflow) |
| how-do-i-get-the-modern-style-matplotlib-plots-often-seen-in-ipython-notebook-ex | How do I get the modern style matplotlib plots often seen in iPython Notebook examples? (stackoverflow) |
| matplotlib-figure-facecolor-background-color | Matplotlib figure facecolor (background color) (stackoverflow) |
| sane-color-scheme-for-matplotlib | Huy Nguyen Blog |
