In [81]:
import matplotlib.pyplot as plt
import numpy as np
In [3]:
f = open("1509878794804.log")
In [4]:
lines = f.readlines()
In [5]:
lines
Out[5]:
In [6]:
lines = lines[1:]
In [7]:
lines = list(map(lambda line: line[:-1].split(','), lines))
In [12]:
lines = list(map(lambda line: [int(line[0]), int(line[1]), int(line[2])], lines))
In [13]:
lines
Out[13]:
In [16]:
ind = 0
mat = []
for i in range(7):
current = []
for j in range(7):
current.append(lines[ind][2])
ind += 1
mat.append(current)
mat
Out[16]:
In [91]:
plt.imshow(mat, interpolation='nearest')
plt.show()
In [139]:
import matplotlib.patches as mpatches
def plot_statistics_from_csv(filename):
with open(filename) as f:
lines = f.readlines()
lines = list(map(lambda line: line[:-1].split(','), lines[1:]))
lines = list(map(lambda line: [int(line[0]), int(line[1]), int(line[2])], lines))
ind = 0
mat = []
for i in range(7):
current = []
for j in range(7):
current.append(lines[ind][2])
ind += 1
mat.append(current)
print(mat)
plt.clf()
im = plt.imshow(mat, cmap='binary', interpolation='nearest')
plt.xticks(range(7), sorted(list(set(list(map(lambda line: line[1], lines))))))
plt.yticks(range(7), sorted(list(set(list(map(lambda line: line[0], lines))))))
values = list(map (lambda line: line[2], lines))
colors = [ im.cmap(im.norm(value)) for value in values]
# create a patch (proxy artist) for every color
patches = [ mpatches.Patch(color=colors[i], label="ns {l}".format(l=values[i]) ) for i in range(len(values)) ]
plt.legend(handles=patches, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0. )
plt.show()
In [140]:
plot_statistics_from_csv("1509880672754.log")
In [141]:
plot_statistics_from_csv("1509901419084.log")
In [ ]: