When I visualize a plot, the default background color is something like gray. I want to have a white end, like the one that I obtain when I save the plot.
Like any other patch, the figure itself has a set_facecolor()
method.
fig = plt.figure()
fig.set_facecolor("w")
You may also directly use the facecolor
argument of plt.figure()
fig = plt.figure(facecolor="w")
A third option is to set the respective rc Parameter. This can either be done in the top of the script
plt.rcParams["figure.facecolor"] = "w"
or by chaning the matplotlib rc file.
Note that from matplotlib version 2.0 on, the default facecolor for figures is actually white, so updating matplotlib is the fourth option available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With