From 35dbf6fcdad29f6bb0030a8b7441030d7239aa99 Mon Sep 17 00:00:00 2001 From: ppwwyyxx Date: Fri, 21 Nov 2014 15:57:44 +0800 Subject: [PATCH] plt by hour --- plot_num_msg_by_time.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/plot_num_msg_by_time.py b/plot_num_msg_by_time.py index e029981..8597402 100755 --- a/plot_num_msg_by_time.py +++ b/plot_num_msg_by_time.py @@ -1,13 +1,13 @@ #!/usr/bin/env python2 # -*- coding: UTF-8 -*- # File: plot_num_msg_by_time.py -# Date: Fri Nov 21 15:19:00 2014 +0800 +# Date: Fri Nov 21 15:57:40 2014 +0800 # Author: Yuxin Wu from lib.Parser import WeChatDBParser from lib.utils import ensure_unicode -from datetime import timedelta +from datetime import timedelta, datetime import numpy as np import matplotlib.pyplot as plt import sys, os @@ -15,9 +15,9 @@ import sys, os if len(sys.argv) != 3: sys.exit("Usage: {0} ".format(sys.argv[0])) -every_k_days = 2 db_file = sys.argv[1] name = ensure_unicode(sys.argv[2]) +every_k_days = 2 parser = WeChatDBParser(db_file) parser.parse() @@ -35,3 +35,19 @@ plt.xlabel("Date") plt.ylabel("Number of msgs in k days") plt.hist(diffs, bins=max_day / every_k_days) plt.show() + +# statistics by hour +# I'm in a different time zone in this period: + +#TZ_DELTA = {(datetime(2014, 7, 13), datetime(2014, 10, 1)): -15} +#def real_hour(x): + #for k, v in TZ_DELTA.iteritems(): + #if x > k[0] and x < k[1]: + #print x + #return (x.hour + v + 24) % 24 + #return x.hour +#hours = [real_hour(x) for x in times] +#plt.ylabel("Number of msgs") +#plt.xlabel("Hour in a day") +#plt.hist(hours, bins=24) +#plt.show()