backgammon/plot.py

35 lines
756 B
Python

import sys
import pandas as pd
from datetime import datetime
import csv
import matplotlib.pyplot as plt
import matplotlib.ticker as mtick
import matplotlib.dates as mdates
from matplotlib.backends.backend_pdf import PdfPages
headers = ['Phase', 'Method', 'Total episodes', 'Episodes', 'Sum', 'Mean']
fig, ax = plt.subplots(1, 1)
plt.ion()
plt.title('Mean over episodes')
plt.xlabel('Episodes')
plt.ylabel('Mean')
plt.grid(True)
#ax.set_xlim(left=0)
ax.set_ylim([-2, 2])
plt.show()
while True:
#df = pd.read_csv(sys.stdin, sep=";", names=headers)
df = pd.read_csv('log', sep=";", names=headers)
x = df['Total episodes']
y = df['Mean']
plt.scatter(x, y, c=[[1,0.5,0]])
print("draw")
#fig.canvas.draw()
plt.pause(2)