How to Change the Background Color in Matplotlib
To change the background color in Matplotlib, set the facecolor: ax.set_facecolor(“lightyellow”) colours the plot area inside the axes, and fig.set_facecolor(“lightblue”) (or plt.figure(facecolor=…)) colours the figure around it. To change the default background color for every plot, set plt.rcParams[“axes.facecolor”] and plt.rcParams[“figure.facecolor”]. This guide covers all of these, plus dark mode with dark_background, transparent PNGs, subplots, the … Read more >>