Skip to content Skip to sidebar Skip to footer

Matplotlib Scatter Array Lengths Are Not Same

i have 2 arrays like this x_test = [[ 14. 1.] [ 14. 2.] [ 14. 3.] [ 14. 4.] [ 14. 5.] [ 14. 6.] [ 14. 7.] [ 14. 8.] [ 14. 9.] [ 14. 10.] [ 14. 11.] [ 14. 12.]

Solution 1:

The x_test, like you provided it, doesn't make sense for a scatter plot. And the arrays are actually not the same size:

print(x_test.shape)
print(y_test.shape)

(12, 2)

(12,)

What you might want to have instead is something like this (using only the second column of x_test):

plt.scatter(x_test[:,1], y_test,  color='black')
plt.plot(x_test[:,1], y_predict, color='blue', linewidth=3)

Post a Comment for "Matplotlib Scatter Array Lengths Are Not Same"