【发布时间】:2021-11-28 04:57:39
【问题描述】:
目前我有这个代码:
def graph_s(self):
ex_list = list()
time = list()
if(len(self.sheet) > 1):
for index, row in self.sheet.iterrows():
ts = date(int(row['Year']), int(row['Month']), 1)
time.append(ts)
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=[date(2021,i,1) for i in z]
y=[i[1] for i in z]
plt.plot(x, y)
plt.show()
main()
else:
print('Sorry! There is not enough information to create a graph of you spending over time.')
main()
但图表不是我想要的。我想将 x 轴更改为更好的版本,例如2021-10,我想省略这一天
【问题讨论】:
-
你是否使用 matplotlib 进行绘图?如果是这样,请将其添加为标签以查找一些 matplotlib 专家。
-
您可以旋转刻度标签:
plt.xticks(rotation=90)
标签: python matplotlib spyder