如何解决如何修复运行本地 Otsu 阈值示例的错误?
我对 Python 非常陌生。我正在尝试运行此脚本:
https://scikit-image.org/docs/0.12.x/auto_examples/segmentation/plot_local_otsu.html
但是,我收到此错误:
Traceback (most recent call last):
File "/Users/janine/Downloads/plot_local_otsu.py",line 37,in <module>
fig,ax = plt.subplots(2,2,figsize=(8,5),sharex=True,sharey=True,File "/usr/local/lib/python3.9/site-packages/matplotlib/_api/deprecation.py",line 471,in wrapper
return func(*args,**kwargs)
File "/usr/local/lib/python3.9/site-packages/matplotlib/pyplot.py",line 1440,in subplots
axs = fig.subplots(nrows=nrows,ncols=ncols,sharex=sharex,sharey=sharey,**kwargs)
File "/usr/local/lib/python3.9/site-packages/matplotlib/figure.py",line 908,in subplots
axs = gs.subplots(sharex=sharex,squeeze=squeeze,File "/usr/local/lib/python3.9/site-packages/matplotlib/gridspec.py",line 307,in subplots
axarr[row,col] = figure.add_subplot(
File "/usr/local/lib/python3.9/site-packages/matplotlib/figure.py",line 781,in add_subplot
ax = subplot_class_factory(projection_class)(self,*args,**pkw)
File "/usr/local/lib/python3.9/site-packages/matplotlib/axes/_subplots.py",line 36,in __init__
self._axes_class.__init__(self,fig,[0,1,1],**kwargs)
File "/usr/local/lib/python3.9/site-packages/matplotlib/_api/deprecation.py",**kwargs)
File "/usr/local/lib/python3.9/site-packages/matplotlib/axes/_base.py",line 648,in __init__
self.update(kwargs)
File "/usr/local/lib/python3.9/site-packages/matplotlib/artist.py",line 1064,in update
ret.append(func(v))
File "/usr/local/lib/python3.9/site-packages/matplotlib/axes/_base.py",line 1531,in set_adjustable
_api.check_in_list(["box","datalim"],adjustable=adjustable)
File "/usr/local/lib/python3.9/site-packages/matplotlib/_api/__init__.py",line 126,in check_in_list
raise ValueError(
ValueError: 'box-forced' is not a valid value for adjustable; supported values are 'box','datalim'
我完全按照此处的建议安装了 scikit-image
:
https://scikit-image.org/docs/stable/install.html。
我使用的是 macOS Mojave。
解决方法
从链接中可以看出,该示例来自过时的 0.12.x
版本,而 skimage
是当前的稳定版本。而且,正如错误消息所示,错误来自这一行:
0.18.0
显然,这些年来对 fig,ax = plt.subplots(2,2,figsize=(8,5),sharex=True,sharey=True,subplot_kw={'adjustable': 'box-forced'})
成员的处理在 adjustable
中发生了变化。例如,通过简单地删除 matplotlib.pyplot
参数,代码运行得非常好:
subplot_kw
事实上,这也是 fig,sharey=True)
文档中的 updated example 的样子(第二个例子)。注意:您必须自己添加两个 skimage
语句,因为那里给定的代码不完整。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。