Так что у меня было так:Тип ошибки, а затем ValueError: х и у должны иметь одинаковую первую размерность
def graph_data(dateList, countList, name):
xarray = [0,1,2,3,4,5,6]
xarray = np.asarray(xarray)
myticks = dateList
plt.figure(figsize=(9,5))
plt.xticks(xarray, myticks)
plt.plot(xarray, countList, color='r', linewidth='3.0')
plt.ylabel("Activity")
plt.xlabel("Date")
plt.title(name + "'s Activity for the past 7 days")
plt.savefig("graph.png")
Который работал нормально, но как только я запустил его на другой VPS (да, я уже установлены все зависимости с ПГИ), но потом он дал мне ошибку типа, указав, что в plt.plot, countList нужно быть с плавающей точкой, так что я изменил код для этого:
def graph_data(dateList, countList, name):
for n in countList:
fixedList = []
fixedList.append(float(n))
xarray = [0,1,2,3,4,5,6]
myticks = dateList
plt.figure(figsize=(9,5))
plt.xticks(xarray, myticks)
plt.plot(xarray, fixedList, color='r', linewidth='3.0')
plt.ylabel("Activity")
plt.xlabel("Date")
plt.title(name + "'s Activity for the past 7 days")
plt.savefig("graph.png")
но тогда он дал мне эта ошибка:
"have shapes {} and {}".format(x.shape, y.shape))
ValueError: x and y must have same first dimension, but have shapes (7,) and (1,)
поэтому я добавил xarray = np.asarray(xarray)
и fixedList = np.asarray(fixedList)
, но он все еще дает мне ошибку формы. Что я делаю не так?