I have 1 tuple with 2 ready lists like for example the following ones, in which the first contains dates in the format YYYYMMDD and the second contains the number of times a crime happened that day.
tuplo= (['20160130', '20160230', '20160330', '20160430', '20160530', '20160730'] [1, 2, 2, 2, 1, 1])
What I intend to do is a function that shows a graph with the number of crimes that occurred each day, the abscissa corresponding to the years and the ordinances to the number of crimes.
def fazer_grafico(tuplo):
x = list()
for anos in tuplo[0]:
x.append(anos[:4])
# x é uma lista só com os anos
x_tmp = range(0, len(x), len(x)/len(set(x)))
y= grafico[1]
pylab.plot(range(len(x)), y)
x= sorted(set(x))
x.append(" ")
pylab.xticks(x_tmp,sorted(set(y)))
The function is doing the correct graphic however does only do one thing that is my doubt, what can I do and then change in my code so that the abscissas in this case x, take into account the years with 365 and 366 days, because supposedly with 365 the width of the axis will be smaller and with 366 going to be larger