Created
November 29, 2020 04:21
-
-
Save kumpeishiraishi/2f64f28b38b69b7ca186e4d8a8f96313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Your .skk-record location | |
filename = '~/.skk-record' | |
import os | |
import datetime as dt | |
import matplotlib.pyplot as plt | |
import matplotlib.dates as mdates | |
filename = os.path.expanduser(filename) | |
f = open(filename) | |
lines = f.readlines() | |
f.close() | |
dates = [None]*len(lines) | |
words = [None]*len(lines) | |
for (index,line) in enumerate(lines): | |
dstr = line[:24] | |
ddate = dt.datetime.strptime(dstr,'%a %b %d %H:%M:%S %Y') | |
dates[index] = dt.datetime(ddate.year,ddate.month,ddate.day,ddate.hour,ddate.minute,ddate.second) | |
wstr = line[59:] | |
wint = int(wstr) | |
words[index] = wint | |
fig = plt.figure() | |
ax = fig.add_subplot(1,1,1) | |
ax.plot(dates,words,label='SKK jisyo candidates') | |
ax.legend(loc='upper left') | |
ax.xaxis.set_major_locator(mdates.AutoDateLocator()) | |
ax.xaxis.set_major_formatter(mdates.DateFormatter('%b %d')) | |
fig.autofmt_xdate(bottom=0.15,ha='center') | |
start = min(dates) | |
end = max(dates) | |
ax.set_xlim(dt.date(start.year,start.month,start.day),dt.date(end.year,end.month,end.day+1)) | |
ax.set_ylabel('Number of words') | |
plt.savefig('output.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment