[Python] matplotlib 提示错误 module ‘backend_interagg’ has no attribute ‘FigureCanvas’

实干、实践、积累、思考、创新。


Python编程,采用matplotlib绘图,提示一下错误:

AttributeError: module 'backend_interagg' has no attribute 'FigureCanvas'. Did you mean: 'FigureCanvasAgg'?

如下图所示:

根据提示,错误原因是没有设置FigureCanvas参数,该参数用于指定matplotlib的绘图后端参数backen,经查询,采用以下三句代码引用matplotlib库即可解决问题

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

即在使用matplotlib库前,先直接指定backen参数,其中,matplotlib的backen参数有以下可选项

['GTK3Agg', 'GTK3Cairo', 'GTK4Agg', 'GTK4Cairo', 'MacOSX', 'nbAgg', 'QtAgg', 'QtCairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']

You already voted!

  • 相关博文( Related Topics)

[01]. Python 出现”invalid literal for int() with base 10: \xef\xbb\xbf0″ 错误

[02]. [编程笔记] Tuple in Python [Python中的元组]

[03]. [Python][编程][笔记] Python海龟绘图 —— 多边形 Polygon

[04]. [Python][编程][笔记] Python符号计算——求偏微分方程 (Python symbolic computation — solving partial differential equations)

[05]. [Python] 安装PyOpenGL笔记

[06]. [编程][笔记] Python中numpy的求和

[07]. [Python] matplotlib 绘图坐标轴标题显示不全

[08]. [Python] matplotlib 提示错误 module ‘backend_interagg’ has no attribute ‘FigureCanvas’


结构|超限|软件开发|编程|参数化|优化|算法|振动控制|减隔震|有限元|技术培训

追求卓越 脚踏实地 致力于探索和拓展行业设计前沿

WeChat_QRCode

https://www.jdcui.com

合作及技术咨询

COOPERATION & CONTACT

E-mail:jidong_cui@163.com

WeChat & Tel: 13450468449

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.