Skip to content

Instantly share code, notes, and snippets.

@kumpeishiraishi
Created November 29, 2020 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumpeishiraishi/2f64f28b38b69b7ca186e4d8a8f96313 to your computer and use it in GitHub Desktop.
Save kumpeishiraishi/2f64f28b38b69b7ca186e4d8a8f96313 to your computer and use it in GitHub Desktop.
# 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