ValueError: x and y must have same first dimension, but have shapes

CODEDRAGON Development/Python

반응형

 

 

오류메시지

 

plot()함수 호출시 x 데이터와 y 데이터의 개수를 맞추어야 합니다. 개수가 맞지 않아서 나오는 에러 입니다.

ValueError: x and y must have same first dimension, but have shapes (4,) and (5,)

 

plt.plot([1,2,3,4], [12, 22, 33, 44, 55])

plt.show()

 

 

 

 

 

해결방법

x 데이터와 y 데이터의 개수 4개 혹은 5개로 동일하게 맞춰줍니다.

plt.plot([1,2,3,4], [12, 22, 33, 44])

plt.show()

 

plt.plot([1,2,3,4, 5], [12, 22, 33, 44, 55])

plt.show()

 

 



반응형