plt by hour
This commit is contained in:
+19
-3
@@ -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 <[email protected]>
|
||||
|
||||
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} <path to decoded_database.db> <name>".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()
|
||||
|
||||
Reference in New Issue
Block a user