I am trying to make a program to track how many situps and pushups I do every workout and also have it plot the results. I got the tracking part done, but matplotlib is giving me some issues. I have it set to take the last 7 items from the list that contains all my workout data, then plot it with the date as the x axis and situps or pushups on the y. Here is that code:
choice3 = input("Enter stat to be plotted, situps or pushups: ")
x = 1
situplist = []
pushuplist = []
while x <= 7:
datelist = list(user_dict['users'][user].keys())[-x]
str_datelist = str(datelist).split('-')
month = str(str_datelist[1])
day = str(str_datelist[2])
datestring += month + '-' + day + ', '
situps = user_dict['users'][user][datelist]['Situps']
situplist.append(situps)
pushups = user_dict['users'][user][datelist]['Pushups']
pushuplist.append(pushups)
x += 1
split_datestring = datestring.split(', ', 7)
split_datestring.remove('')
split_datestring.reverse()
situplist.reverse()
pushuplist.reverse()
if choice3.upper() == 'SITUPS':
plt.plot(split_datestring, situplist)
plt.xlabel("DATE")
plt.ylabel(choice3.upper())
plt.show()
The last 7 situps values are as follows: 30, 20, 0, 50, 30, 0, 30
matplotlib plots it like this though:
Obviously, I'm wanting the y axis to start at 0, but even when I add plt.axis([split_datestring[0], split_datestring[-1], 0, 50])
I just get this:
Does anyone know how to fix this? TIA!