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

时间:2018-10-04 20:24:00

标签: python pandas matplotlib

您好,我使用熊猫来绘制此图。使用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

0 个答案:

没有答案