factor out some common code; ensure x and y axes pair exactly
This commit is contained in:
parent
ac668f0a1a
commit
f5d5e02275
|
@ -37,12 +37,16 @@ def combineDailyToWeekly(pj, func):
|
|||
return [func(pj[i : i + chunkSize]) for i in range(0, len(pj), chunkSize)]
|
||||
|
||||
|
||||
def getLastElem(arr):
|
||||
return arr[-1]
|
||||
|
||||
|
||||
def getDownloadsWeekly(t):
|
||||
return combineDailyToWeekly(t[0], lambda _: _[-1]), combineDailyToWeekly(t[1], sum)
|
||||
return combineDailyToWeekly(t[0], getLastElem), combineDailyToWeekly(t[1], sum)
|
||||
|
||||
|
||||
def getUpdatesWeekly(t):
|
||||
return combineDailyToWeekly(t[0], lambda _: _[-1]), combineDailyToWeekly(t[2], sum)
|
||||
return combineDailyToWeekly(t[0], getLastElem), combineDailyToWeekly(t[2], sum)
|
||||
|
||||
|
||||
def getDownloadsDaily(t):
|
||||
|
@ -61,6 +65,8 @@ def plotData(filename, ylabel, timespan, x, y):
|
|||
import matplotlib.pyplot as plt
|
||||
import matplotlib.dates as mdates
|
||||
|
||||
assert len(x) == len(y)
|
||||
|
||||
plt.clf()
|
||||
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d"))
|
||||
plt.gca().xaxis.set_major_locator(mdates.AutoDateLocator())
|
||||
|
|
Loading…
Reference in New Issue