【发布时间】:2018-11-27 14:38:21
【问题描述】:
我目前正在尝试在 Jupyter Notebook 中将插入轴绘制到 matplotlib 图中,但我总是收到以下错误:
TypeError: get_tightbbox() got an unexpected keyword argument 'bbox_extra_artists'
最小的工作示例:
%matplotib inline
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import numpy as np
fig, axis = plt.subplots(1, 1)
axis.imshow(np.random.rand(5, 5))
ins_axes = inset_axes(axis, width=0.75, height=0.75, loc=1)
如果我将代码作为脚本运行或不使用%matplotlib inline,这就是输出的样子:
我的 matplotlib 版本是 3.0.1,jupyter 是 1.0.0,Python 是 3.6.7。
我最近从 matplotlib 1 升级,一切正常。
编辑:matplotlib 3.0.0 导致另一个错误更早出现:
AttributeError: module 'matplotlib' has no attribute 'artist'
EDIT2:升级到 matplotlib 3.0.2 成功了,请参阅 ImportanceOfBeingErnest's 答案!
【问题讨论】:
标签: python-3.x matplotlib plot jupyter-notebook