plot() got an unexpected keyword argument 'y'
时间: 2023-10-01 09:11:56 浏览: 92
This error message usually occurs when you are trying to pass an invalid argument to the plot() function in Python.
The 'plot()' function in Python is used to create line plots. It takes two mandatory arguments 'x' and 'y', which represent the values for x-axis and y-axis respectively. Additionally, it also accepts several optional arguments to customize the plot.
In this case, the error message 'plot() got an unexpected keyword argument 'y'' indicates that you are trying to pass an invalid argument to the plot() function. Specifically, you are trying to pass an argument named 'y', which is not a valid argument for the plot() function.
To fix this issue, you should check the arguments you are passing to the plot() function and make sure that they are valid. The valid arguments for the plot() function are 'x', 'y', 'color', 'marker', 'linestyle', 'linewidth', 'label', etc.
For example, if you want to create a line plot with x and y values, you can use the following code:
```
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5]
y = [10, 20, 30, 40, 50]
plt.plot(x, y)
plt.show()
```
This code will create a line plot with x-axis values from 1 to 5 and y-axis values from 10 to 50.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)