-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcase_of_X_movies.py
48 lines (33 loc) · 994 Bytes
/
case_of_X_movies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import xfast
import matplotlib.pyplot as plt
YEAR_SHIFT = 1950
order = 6
ticks, years = [], []
for year in open('years.txt','rb').readlines():
ticks.append(year)
years.append(int(year) - YEAR_SHIFT)
titles = []
for i, title in enumerate(open('result.txt','rb').readlines()):
titles.append(title[:-1]+' ('+str(years[i] + YEAR_SHIFT)+')')
mytrie = xfast.Xtrie(order)
for year in years:
mytrie.mark(year)
# mytrie.self_report()
atake = mytrie.visualize()
fig, ax = plt.subplots()
fig.set_size_inches(10,5)
ax.set_frame_on(False)
c = plt.pcolor(atake,cmap=plt.cm.Blues, alpha=0.8,edgecolors='k', linewidths=1)
ax.invert_yaxis()
plt.xticks(rotation=90)
ax = plt.gca()
for t in ax.xaxis.get_major_ticks():
t.tick1On = False
t.tick2On = False
for t in ax.yaxis.get_major_ticks():
t.tick1On = False
t.tick2On = False
ax.xaxis.set_ticks([float(year)+0.5 for year in years])
ax.xaxis.set_ticklabels(titles, fontsize=10)
plt.tight_layout()
plt.savefig('movies.png')