使用MatPlotlib绘制X与Y的散点图或使用第三变量b绘制Pandas

2024-04-23 18:51:03 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨,我用熊猫来画这个。我使用Matplotlib时出错。你知道吗

  zero_term = 0
one_term = 0
two_term = 0
for i in range(logistic_Y.shape[0]):
    if logistic_Y[i]<21.3:
        logistic_Y[i] = 0
        zero_term += 1
    if ((21.3<logistic_Y[i]) and (logistic_Y[i]<33.9)):
         logistic_Y[i]=1
         one_term += 1
    if(logistic_Y[i]>33.9):
         logistic_Y[i] = 2
         two_term +=1 

logistic_Y = pd.DataFrame(logistic_Y)
print(logistic_Y.shape)
i = X[columns[3]]
j = X[columns[2]]

plt.figure()
plt.scatter(X.origin,X.displacement, c = logistic_Y ,cmap="jet", lw=0)
plt.show

ValueError:“c”参数有392个元素,不能与大小为392的“x”和大小为392的“y”一起使用。你知道吗

1https://i.stack.imgur.com/HNCk1.png数据集 division of X and Y


Tags: columnsandinforifmatplotlibrangeplt