Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.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 在线性回归模型中,如何为x值和y值指定颜色?_Python_Numpy_Matplotlib_Seaborn - Fatal编程技术网

Python 在线性回归模型中,如何为x值和y值指定颜色?

Python 在线性回归模型中,如何为x值和y值指定颜色?,python,numpy,matplotlib,seaborn,Python,Numpy,Matplotlib,Seaborn,颜色为蓝色,用于绘图。如何为y值指定红色这就是您想要的吗 x = 10 * np.random.rand(100) y = 3 * x + np.random.randn(100) plt.figure(figsize = (10, 8)) plt.scatter(x, y); 您必须具有恒定的颜色,或者将颜色映射到某个值。如果要将颜色映射到y x = 10 * np.random.rand(100) y = 3 * x + np.random.randn(100) plt.figure(fi

颜色为蓝色,用于绘图。如何为y值指定红色

这就是您想要的吗

x = 10 * np.random.rand(100)
y = 3 * x + np.random.randn(100)
plt.figure(figsize = (10, 8))
plt.scatter(x, y);

您必须具有恒定的颜色,或者将颜色映射到某个值。如果要将颜色映射到
y

x = 10 * np.random.rand(100)
y = 3 * x + np.random.randn(100)
plt.figure(figsize = (10, 8))
# c='r' gives red color
plt.scatter(x, y, c='r');
否则,如果您需要恒定的颜色,您可以

 plt.scatter(x, y c=y)
 plt.scatter(x, y, c='r')