Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python matplotlib中的ValueError,即使数组长度相同_Python_Matplotlib_Valueerror - Fatal编程技术网

Python matplotlib中的ValueError,即使数组长度相同

Python matplotlib中的ValueError,即使数组长度相同,python,matplotlib,valueerror,Python,Matplotlib,Valueerror,我的数组如下: x = ['2.000000', '2.100000', '2.200000', '2.300000', '2.400000', '2.500000'] y = ['-0.876484', '-0.841230', '-0.776523', '-0.724883', '-0.656426', '-0.595879'] e = ['0.000655', '0.000851', '0.001311', '0.001642', '0.001702', '0.001709'] impo

我的数组如下:

x = ['2.000000', '2.100000', '2.200000', '2.300000', '2.400000', '2.500000']
y = ['-0.876484', '-0.841230', '-0.776523', '-0.724883', '-0.656426', '-0.595879']
e = ['0.000655', '0.000851', '0.001311', '0.001642', '0.001702', '0.001709']
import matplotlib.pyplot as plt

x = ['2.000000', '2.100000', '2.200000', '2.300000', '2.400000', '2.500000']
y = ['-0.876484', '-0.841230', '-0.776523', '-0.724883', '-0.656426', '-0.595879']
e = ['0.000655', '0.000851', '0.001311', '0.001642', '0.001702', '0.001709']
plt.errorbar(x, y, yerr=e, fmt='o')
plt.show()
我用错误条绘制的代码如下:

x = ['2.000000', '2.100000', '2.200000', '2.300000', '2.400000', '2.500000']
y = ['-0.876484', '-0.841230', '-0.776523', '-0.724883', '-0.656426', '-0.595879']
e = ['0.000655', '0.000851', '0.001311', '0.001642', '0.001702', '0.001709']
import matplotlib.pyplot as plt

x = ['2.000000', '2.100000', '2.200000', '2.300000', '2.400000', '2.500000']
y = ['-0.876484', '-0.841230', '-0.776523', '-0.724883', '-0.656426', '-0.595879']
e = ['0.000655', '0.000851', '0.001311', '0.001642', '0.001702', '0.001709']
plt.errorbar(x, y, yerr=e, fmt='o')
plt.show()
我一直听到一个错误,说:

ValueError: err must be a scalar, the same dimensions as x, or 2xN.

我不明白为什么会这样,因为我所有数组的维数都是相等的。

您正在绘制字符串,这就是matplotlib无法处理e的形状的原因。 将数据更改为数字,它就会工作:(您的
e
太小,这就是错误条不显示的原因)


我认为您的数据都是字符串是一个问题。请尝试
plt.errorbar(list(map(float,x))、list(map(float,y))、yerr=list(map(float,e))、fmt='o')