UPDATE: Although there is a similar discussion here I'm keeping my question given the confusing/non-intuitive attribute that needs to be used to change a subplot background color. Hopefully the language I use to describe the issue will further help some confused coders.
BACKGROUND: I need to plot a series of charts, with various formats and data. When using Matplotlib's standard style, here is an example of what I get. Note that both the FIGURE and SUBPLOTS backgrounds are all white.
With rcParams I can quickly change the set-up for all my charts, which avoids me having to change the format for each chart individually. It also helps me to keep a certain standard on my charts, making them look professional.
THE ISSUE: As all my spreadsheets (see here a code I wrote to convert Excel spreadsheets to dark-format), browsers, etc are all in dark-format, I wanted to have my chart in Python also in dark format. Using rcParams was the best way to do it, given how small the code is:
import matplotlib.pyplot as plt rgb_color = [51,51,51] #color in RGB format rgb_decimal_1 = [x / 255.0 for x in rgb_color] #RGB color in "decimals" #set colors for all charts parameters params = {'text.color':'white', 'xtick.color':'white', 'ytick.color':'white', 'figure.facecolor':rgb_decimal_1} plt.rcParams.update(params) With this simple code, I change almost all the colors I needed to make my charts dark. There is one part, however, I can't figure out a way to do: the SUBPLOTs background. See how the same charts look when ruing the code above. Observe that although the FIGURE background is now dark (and the letters are in white, etc), the SUBPLOT backgrounds are still white:
Note that I know how to make the subplots dark. If I add the simple code below, when plotting each subplot, I can make the subplot background dark. See the output just after the code:
rgb_color = [41,41,41] #color in RGB format rgb_decimal = [x / 255.0 for x in rgb_color] #RGB color in decimal format chart_p.set_facecolor((rgb_decimal)) #set color background of each chart subplot Having to include the code above on each subplot however is exactly what I want to avoid. The documentation on how to use rcParams is very good (see it here). But I can't find a setup for the SUBPLOTs backgrounds. I was expecting on the "figure subplot parameters" something like figure.subplot.facecolor but it doesn't exist.
Am I missing something obvious? I know that there is a way to set the SUBPLOTs background color since if I use the style "dark background" [plt.style.use('dark_background')] the charts SUBPLOT background goes to black. Close but not the color that I want.



'axes.facecolor'. Add'axes.facecolor': 'black'(or whatever color) to yourparams.