AttributeError: Unknown property axisbg

AttributeError: Unknown property axisbg

这是我正在尝试的代码 运行:

ax = plt.axes(axisbg='#E6E6E6')
ax.set_axisbelow(True)
plt.grid(color='w',linestyle='solid')

for spine in ax.spines.values():
   spine.set_visible(False)

ax.xaxis.tick_bottom()
ax.yaxis.tick_left()

ax.tick_params(colors='gray',direction='out')
for tick in ax.get_xticklabels():
   tick.set_color('gray')
for tick in ax.get_yaxislabels():
   tick.set_color('gray')

ax.hist(x,edgecolor='E6E6E6',color='E6E6E6');

错误是:AttributeError: Unknown 属性 axisbg

请帮我找出错误。

axisbg 在 matplotlib 2.0+ 中被弃用 请改用 facecolor。

https://matplotlib.org/api/api_changes.html

替换下面这行代码

ax = plt.axes(axisbg='#E6E6E6')

ax = plt.axes(facecolor='#E6E6E6')