ValueError: x and y must have same first dimension, but have shapes (1, 120) and (120,)

1893 ワード

ValueError: x and y must have same first dimension, but have shapes (1, 120) and (120,)
エラー・コードは次のとおりです.

import random
from matplotlib import pyplot  as  plt

x = [range(0, 120)]   #➀
y = [random.randint(20, 35) for item in range(120)]


plt.plot(x, y, color='green') #➁
plt.show()


➁であるxはrangタイプを入力すべきであるが、➀ではlistタイプであるため、➀でのコードをx = range(0, 120)に変更すればよい