Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.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 SyntaxError:无效语法[plt.scatter]_Python_Matplotlib - Fatal编程技术网

Python SyntaxError:无效语法[plt.scatter]

Python SyntaxError:无效语法[plt.scatter],python,matplotlib,Python,Matplotlib,我准备了一个多项式回归模型,一切似乎都很好,只是matplotlib有问题!我不知道到底是怎么回事!代码如下: plt.scatter(X,y,color='Red') plt.plot(X , lin_reg.predict(X),color='Blue') plt.title('Truth') plt.xlabel('Position') plt.ylabel('Salary') plt.show() 下面是错误:--- 文件“”,第3行 plt.散射(X,y,color='Red') ^

我准备了一个多项式回归模型,一切似乎都很好,只是matplotlib有问题!我不知道到底是怎么回事!代码如下:

plt.scatter(X,y,color='Red')
plt.plot(X , lin_reg.predict(X),color='Blue')
plt.title('Truth')
plt.xlabel('Position')
plt.ylabel('Salary')
plt.show()
下面是错误:---

文件“”,第3行
plt.散射(X,y,color='Red')
^
SyntaxError:无效语法

根据文档,
重塑
至少接收2个参数(您只提供了一个):


除了同意不应该粘贴代码图像(复制粘贴代码是同一个过程),您在标题中描述的错误并不是您显示的错误<代码>np。重塑需要两个参数,要重塑的数组和新的形状,您只提供了一个,它已解释为原始数组。该错误消息与
plt
或无效语法无关。请在前一行计算括号。
File "<ipython-input-15-697418dc1afd>", line 3
    plt.scatter( X,y,color='Red')
      ^
SyntaxError: invalid syntax
numpy.reshape(a, newshape, order='C')
where:
- a : array_like
Array to be reshaped.
 - newshape : int or tuple of ints
The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.