-->

Monday, February 1, 2021

Setting the Background Color of Matplotlib Images

I ran into an issue where viewing Matplotlib images in a dark mode browser or editor wasn't showing the axis of the plots. To fix this you can run one of the following at the top of your editor:


mpl.rcParams['figure.facecolor'] = 'white'
#or

import matplotlib.pyplot as plt
plt.style.use({'figure.facecolor':'white'})
 

Supposedly you can also put `figure.facecolor: white` in your matplotlibrc file, but I haven't gotten that to work yet.

Now the plots all look like this: