【发布时间】:2021-11-28 03:08:21
【问题描述】:
目前我有这个代码:
def graph_s(self):
ex_list = list()
time = list()
if(len(self.sheet) > 1):
for index, row in self.sheet.iterrows():
time.append(row['Month']/12 + row['Year'])
ex_list.append(float(row['grocery']) + float(row['transportation']) + float(row['leisure']) + float(row['utilities']) + float(row['savings']) + float(row['bills']))
z = sorted(zip(time,ex_list))
x=[i[0] for i in z]
y=[i[1] for i in z]
plt.plot(x, y)
plt.show()
else:
print('Sorry! There is not enough information to create a graph of you spending over time.')
但是,x 轴不是我想要的。我想在 x 轴上显示月份和年份,从最旧到新。当我运行代码时,它显示了下图。
【问题讨论】: