Add simple matplotlib bar plots per run
This commit is contained in:
54203
copycat.log
54203
copycat.log
File diff suppressed because it is too large
Load Diff
@ -1 +1,2 @@
|
|||||||
from .copycat import Copycat, Reporter # noqa
|
from .copycat import Copycat, Reporter # noqa
|
||||||
|
from .plot import plot_answers
|
||||||
|
|||||||
18
copycat/plot.py
Normal file
18
copycat/plot.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import matplotlib.pyplot as plt; plt.rcdefaults()
|
||||||
|
import numpy as np
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
|
||||||
|
def plot_answers(answers):
|
||||||
|
answers = sorted(answers.items(), key=lambda kv : kv[1]['count'])
|
||||||
|
objects = [t[0] + ' (temp:{})'.format(t[1]['avgtemp']) for t in answers]
|
||||||
|
yvalues = [t[1]['count'] for t in answers]
|
||||||
|
|
||||||
|
y_pos = np.arange(len(objects))
|
||||||
|
|
||||||
|
plt.bar(y_pos, yvalues, align='center', alpha=0.5)
|
||||||
|
plt.xticks(y_pos, objects)
|
||||||
|
plt.ylabel('Count')
|
||||||
|
plt.title('Answers')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
4
main.py
4
main.py
@ -2,7 +2,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from copycat import Copycat, Reporter
|
from copycat import Copycat, Reporter, plot_answers
|
||||||
|
|
||||||
class SimpleReporter(Reporter):
|
class SimpleReporter(Reporter):
|
||||||
def report_answer(self, answer):
|
def report_answer(self, answer):
|
||||||
@ -27,5 +27,7 @@ def main():
|
|||||||
for answer, d in sorted(iter(answers.items()), key=lambda kv: kv[1]['avgtemp']):
|
for answer, d in sorted(iter(answers.items()), key=lambda kv: kv[1]['avgtemp']):
|
||||||
print('%s: %d (avg time %.1f, avg temp %.1f)' % (answer, d['count'], d['avgtime'], d['avgtemp']))
|
print('%s: %d (avg time %.1f, avg temp %.1f)' % (answer, d['count'], d['avgtime'], d['avgtemp']))
|
||||||
|
|
||||||
|
plot_answers(answers)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user