zl程序教程

您现在的位置是:首页 >  其它

当前栏目

已解决AttributeError: Unknown property axisbg

解决 Property unknown AttributeError
2023-09-27 14:27:32 时间

已解决AttributeError: Unknown property axisbg

在这里插入图片描述

报错问题

之前在工作中遇到过这个坑,记录一下问题以及解决方法,不一定针对所有情况都能用,但是可以供大家参考。
问题描述如下:

raise AttributeError(‘Unknown property %s’ % k)
AttributeError: Unknown property axisbg

引发属性错误(“未知属性%s”%k)
属性错误:未知属性axisbg

在这里插入图片描述

解决方法

在这里插入图片描述
在matplotlib.pyplot.subplot2grid()的属性栏里面已经没有了axisbg这个参数,根据matplotlib 2.2.0的API,
Color of Axes
The axisbg and axis_bgcolor properties on Axes have been deprecated in favor of facecolor.

得知,曾经包含的属性axisbg已经被facecolor所替换:
ax = plt.subplot2grid((2,1), (1,0), rowspan=4, colspan=4, facecolor=’#07000d’)
同样的,matplotlib里面也去掉了 finance包,现在有个独立的库 mpl_finance,如果想用原来finance库中的函数,比如 candlestick_ochl,就需要从mpl_finance中导入了。

PS

有问题评论区留言即可