我有2个阵列:
t1 = array([[963],
[964],
[965],
[966]])
f1 = array([[ 3.52473569],
[ 3.52473569],
[ 3.52473569],
[ 3.52473569]], dtype=float32)
这两个阵列具有相同的长度,相同的尺寸。但是,当我尝试时:
plt.fill_between(t1, f1)
我收到了这个错误:
File "<ipython-input-126-986395e7c03f>", line 1, in <module>
plt.fill_between(t1, f1)
File "C:\opt\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 2896, in fill_between
**kwargs)
File "C:\opt\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 1818, in inner
return func(ax, *args, **kwargs)
File "C:\opt\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py", line 4596, in fill_between
raise ValueError("Argument dimensions are incompatible")
ValueError: Argument dimensions are incompatible
但是t1和f1在此命令中起作用:
plt.fill(t1, f1)
请告诉我错误在哪里。
答案 0 :(得分:1)
这是因为您将嵌套列表传递给fill_between
。尝试按照以下方式展平您的列表:
t1 = array([[963],
[964],
[965],
[966]]).flatten()
f1 = array([[3.52473569],
[3.52473569],
[3.52473569],
[3.52473569]], dtype=float).flatten()