我是靠谱客的博主 傲娇月饼,这篇文章主要介绍pandas绘图报错Pandas绘图报错:AttributeError: module ‘backend_interagg’ has no attribute ‘FigureCanvas’. Did you mean: ‘FigureCanvasAgg’?,现在分享给大家,希望可以做个参考。
Pandas绘图报错:AttributeError: module ‘backend_interagg’ has no attribute ‘FigureCanvas’. Did you mean: ‘FigureCanvasAgg’?
报错信息

原代码如下
import pandas as pd
# 创建数据
array1 = [1, 2, 3]
array2 = [2, 3, 4]
charts_data = pd.DataFrame({'array1': array1, 'array2': array2})
# 线性图
charts_data.plot()
解决思路
-
根据报错显示执行代码使用到了 matplotlib ,我们导入 matplotlib 模块
-
matplotlib 的 backend 使用的是默认配置 agg (agg不能显示绘制的图),要想显示绘制的图需要更改 agg 为 TkAgg
-
调用 plt.show() 函数将绘制的图像展示出来
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('TkAgg')
# 创建数据
array1 = [1, 2, 3]
array2 = [2, 3, 4]
charts_data = pd.DataFrame({'array1': array1, 'array2': array2})
# 线性图
charts_data.plot()
# 显示图表
plt.show()
运行结果

最后
以上就是傲娇月饼最近收集整理的关于pandas绘图报错Pandas绘图报错:AttributeError: module ‘backend_interagg’ has no attribute ‘FigureCanvas’. Did you mean: ‘FigureCanvasAgg’?的全部内容,更多相关pandas绘图报错Pandas绘图报错:AttributeError:内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复