python - matplotlib 删除 IndexError: tuple index out of range after upgrade
问题描述
我在升级 Python 库时犯了一个错误,现在 matplotlib 出现以下错误:
IndexError:元组索引超出范围
在昨天工作的一个非常简单的代码上。
考虑一下我昨天绘制的这个大 CSV 文件:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
headers = ['fx', 'fy', 'fz', 'tx', 'ty', 'tz', 'currentr',
'time', 'theta', 'omegay', 'currenty', 'pr', 'Dc', 'Fr', 'Fl']
df = pd.read_csv('20190802_pase3part1_test3PC-c156.csv', names=headers)
fig3 = plt.figure()
plt.plot(df.index, df['time'])
plt.show()
但升级后我收到错误:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-5-1ce3610bc7d8> in <module>
1 fig3 = plt.figure()
----> 2 plt.plot(df.index, df['time'])
3 plt.show()
c:\python37\lib\site-packages\matplotlib\pyplot.py in plot(scalex, scaley, data, *args, **kwargs)
2793 return gca().plot(
2794 *args, scalex=scalex, scaley=scaley, **({"data": data} if data
-> 2795 is not None else {}), **kwargs)
2796
2797
c:\python37\lib\site-packages\matplotlib\axes\_axes.py in plot(self, scalex, scaley, data, *args, **kwargs)
1664 """
1665 kwargs = cbook.normalize_kwargs(kwargs, mlines.Line2D._alias_map)
-> 1666 lines = [*self._get_lines(*args, data=data, **kwargs)]
1667 for line in lines:
1668 self.add_line(line)
c:\python37\lib\site-packages\matplotlib\axes\_base.py in __call__(self, *args, **kwargs)
223 this += args[0],
224 args = args[1:]
--> 225 yield from self._plot_args(this, kwargs)
226
227 def get_next_color(self):
c:\python37\lib\site-packages\matplotlib\axes\_base.py in _plot_args(self, tup, kwargs)
397 func = self._makefill
398
--> 399 ncx, ncy = x.shape[1], y.shape[1]
400 if ncx > 1 and ncy > 1 and ncx != ncy:
401 cbook.warn_deprecated(
IndexError: tuple index out of range
我认为这是一个错误,但我不知道是什么原因造成的。
我的环境是:
- matplotlib:3.1.1
- 蟒蛇:3.7.4
- 操作系统:Windows 1809(操作系统内部版本 17763.615)
如果您能帮助我了解问题所在以及如何解决,我将不胜感激?
PS1。我刚刚在另一台使用 matplotlib 的计算机上尝试了代码3.0.3
,它就成功了!
PS2。在这里发出一个错误
PS3。我刚刚尝试通过以下方式降级到以前的版本:
pip uninstall matplotlib
pip install matplotlib==<version>
但它没有用!
PS4。好的,事实证明这是一个熊猫错误。降级0.25
解决0.24
问题!(详情)
解决方案
推荐阅读
- azure-keyvault - Azure KeyVault 加密 API 终结点不返回 Base64 编码字符串
- c# - 错误:转储到表进程:找不到路径的一部分
- wpf - 如何使 mainWindow 的某些元素在其他视图中通用?
- c++ - 你将如何编写一个函数来创建一个链表?
- mysql - Mysql - 在数组中找到 JSON_CONTAINS
- azure - 如何通过具有最大数据处理限制的 API 处理大量数据
- java - Spring boot webflux R2DBC 性能问题
- cython - cython中未解析的外部符号asm
- r - 在多列的静态列(平均值)中获取值并减去值
- angular - 如何转换 Observable
到其他 Observable