gpt4 book ai didi

python - pyplot.scatter(c ='red')。无效的语法?

转载 作者:行者123 更新时间:2023-11-30 09:33:03 25 4
gpt4 key购买 nike

我是机器学习的初学者,我在 pyplot 的分散方法中遇到了颜色错误,“s=None”参数也出现了同样的错误

pyplot.scatter = (X_train, y_train, c = 'red')
pyplot.plot = (X_train, regressor.predict(X_train), c = 'blue')

我收到此错误

plt.scatter = (X_train, y_train, c = 'red')
^
SyntaxError: invalid syntax

如何消除此错误以及何时将“color = 'red'”替换为“c = 'red'”?

最佳答案

您必须删除=:

pyplot.scatter(X_train, y_train, c = 'red')
pyplot.plot(X_train, regressor.predict(X_train), c = 'blue')
PS。按照惯例,通常以这种方式导入 matplotlib 库:

import matplotlib.pyplot as plt
plt.scatter(X_train, y_train, c = 'red')

关于python - pyplot.scatter(c ='red')。无效的语法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50961057/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com