'Matplotlib - not showing background when plotting again same plot
I am plotting 4 subplots on 1 figure with code below. When I try to plot the same plot in the notebook later just with fig I receive the same plot but with no white background, it is transparent. Any idea why it happens and what should I do to also get white background in next plot?

fig, axes = plt.subplots(figsize=(14, 10), nrows=2, ncols=2)
vec1 = np.random.randint(1,11,100)
vec2 = np.random.rand(100)
vec3 = np.random.randn(100)
vec4 = np.random.random(100)
axes[0, 0].plot(vec1, label='1')
axes[0, 1].hist(vec2, bins=20, edgecolor='k')
axes[1, 0].plot(vec3, label='3')
axes[1, 1].hist(vec4, bins=20, edgecolor='k')
axes[0][0].set_title("randint", fontsize=15)
axes[0][1].set_title("rand", fontsize=15)
axes[1][0].set_title("randn", fontsize=15)
axes[1][1].set_title("random", fontsize=15)
fig.legend(loc='upper left')
fig.suptitle("Losowe wektory", fontsize=18)
fig.subplots_adjust(left=0.1, bottom=0.05, right=0.9, top=0.9, wspace=0.15, hspace=0.35)
Solution 1:[1]
fig, axes = plt.subplots(figsize=(14, 10), nrows=2, ncols=2, facecolor='white')
Setting facecolor to white solves the problem, first I thought it is would be basically white and we have to set transparency to get it but it is otherwise as I can see.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Inf |
