无法让我绘制 2 个列表的简单意图起作用。1dim 列表的长度都相同,并且列表值是简单的浮点数,逗号后只有数字。长变量名可能是可疑的,因为我研究了一些 pyplot 不喜欢某些名称的情况。无论如何,代码看起来像这样(列表本身由我打印+复制粘贴):
countErrXPercent_allX_ABC = [0, 0.0, 0.0, 4.55, 5.41, 15.69, 23.44, 29.27, 32.05, 47.95, 48.0, 64.91, 43.94, 57.35, 52.27, 70.59, 79.55, 73.53, 77.14, 64.52, 77.78, 80.0, 82.61, 72.0, 86.96, 74.07, 77.78, 66.67, 60.0, 55.56, 80.0, 90.91, 77.78, 75.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, -1.0, 100.0, 100.0]
countErrYPercent_allY_ABC = [0, -1.0, 0.0, 10.0, 12.5, 22.22, 43.59, 48.61, 53.42, 67.37, 71.83, 78.65, 74.32, 72.88, 68.97, 82.69, 88.37, 77.27, 84.62, 85.0, 86.67, 90.0, 93.94, 83.33, 87.5, 80.95, 83.33, 92.86, 83.33, 57.14, 81.82, 100.0, 75.0, 100.0, 100.0, 60.0, 100.0, 50.0, 83.33, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0]
P.plot(countErrXPercent_allX_ABC, '.', 'b', label='aErr < bErr')
P.plot(countErrYPercent_allY_ABC, '.', 'r', label='aErr < cErr')
P.show()
错误信息:
Traceback (most recent call last):
File "xyz.py", line 169, in errClassesX
P.plot(countErrXPercent_allX_ABC, '.', 'b', label='aErr < bErr')
File "C:\Program Files (x86)\Python\lib\site-packages\matplotlib\pyplot.py", line 2817, in plot
ret = ax.plot(*args, **kwargs)
File "C:\Program Files (x86)\Python\lib\site-packages\matplotlib\axes.py", line 3996, in plot
for line in self._get_lines(*args, **kwargs):
File "C:\Program Files (x86)\Python\lib\site-packages\matplotlib\axes.py", line 330, in _grab_next_args
for seg in self._plot_args(remaining, kwargs):
File "C:\Program Files (x86)\Python\lib\site-packages\matplotlib\axes.py", line 308, in _plot_args
x, y = self._xy_from_xy(x, y)
File "C:\Program Files (x86)\Python\lib\site-packages\matplotlib\axes.py", line 248, in _xy_from_xy
raise ValueError("x and y must have same first dimension")
ValueError: x and y must have same first dimension
令人困惑的是,当打印这些列表+将其复制粘贴到一个新的空文件中时(使用新变量'l'和'k',pyplot可以工作。我试图绘制列表的重复项(copy.copy()命令)并分配新的 varNames,但不幸的是没有成功。因此,任何想法都受到高度赞赏。