python - 如何纠正python填充之间的错误,TypeError:'PolyCollection'对象不可迭代
问题描述
下面的代码片段打印出 fill_between 命令的 x、y1 和 y2 输入的类型和形状。我收到以下运行时错误“TypeError:'PolyCollection' 对象不可迭代”。我该如何纠正?
x_fill = x_fill.reshape((n_steps_fcst, ))
y1_fill = y1_fill.reshape((n_steps_fcst, ))
y2_fill = y2_fill.reshape((n_steps_fcst, ))
print('type(x_fill): ', type(x_fill), ', x_fill.shape: ', x_fill.shape)
print('type(y1_fill): ', type(y1_fill), ', y1_fill.shape: ', y1_fill.shape)
print('type(y2_fill): ', type(y2_fill), ', y2_fill.shape: ', y2_fill.shape)
ax_y.append(fig.add_subplot(ny, n_columns, iy * n_columns + 1))
lin, = ax_y[iy].fill_between(x_fill, y1_fill, y2_fill)
输出是
type(x_fill): <class 'numpy.ndarray'> , x_fill.shape: (99,)
type(y1_fill): <class 'numpy.ndarray'> , y1_fill.shape: (99,)
type(y2_fill): <class 'numpy.ndarray'> , y2_fill.shape: (99,)
回溯(最近一次通话最后):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1\helpers\pydev\pydevd.py", line 1741, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1\helpers\pydev\pydevd.py", line 1735, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1\helpers\pydev\pydevd.py", line 1135, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Documents/git_spork/Project/time_series_plot_2.py", line 371, in <module>
main()
File "C:/Users/Documents/git_spork/Project/time_series_plot_2.py", line 276, in main
lin, = ax_y[iy].fill_between(x_fill, y1_fill, y2_fill)
TypeError: 'PolyCollection' object is not iterable
解决方案
推荐阅读
- android - 在 Android Studio 4.0(Canary) 中找不到预览窗口的位置
- typescript - 如何扩展 $options 属性的类型?
- javascript - 如何仅使用 Node.js 后端代码将浏览器重定向到另一个站点?
- git - 如何防止“开发”被合并到“发布”中?
- python - 为什么我收到的 ARP 数据包总是有相同的 MAC 地址?
- emacs - 每次我重新安排任务时如何插入预定时间来记录
- google-cloud-platform - 允许每个用户拥有 Google Cloud Storage 对象所有权的 IAM/ACL 政策
- node.js - ReferenceError:尝试在 linux 的命令行上运行灯塔报告时未定义 URL
- scala - 如何修复 Spark 聚合最大值 ` 错误中包含无效字符?
- neo4j - 有没有办法在 Neo 中为关系创建唯一约束