调整matplotlib绘制图形的背景颜色
1、首先看一下matplotlib绘制的二维图形,默认的非绘图区和绘图区的颜色都是白色的,运行以下代码:import matplotlib.pyplot as pltfig = plt.figure(figsize=(5,3))sns.reset_orig()x = np.arange(1,11)y = x*2 + 4plt.plot(x,y)plt.show()

3、第二种方法:通过fig.patch.set_facecolor()函数设定非绘图区颜色,运行以下代码将非绘图区颜色设置为灰色lightgrey:fig = plt.figure(figsize=(5,3))fig.patch.set_facecolor('lightgrey')plt.plot(x,y)
