backgammon/plot.py

37 lines
811 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', 'Start 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)
df['Total episodes'] = df['Start episodes'] + 100
print(df)
x = df['Total episodes']
y = df['Mean']
plt.scatter(x, y, c=[[1,0.5,0]])
#fig.canvas.draw()
plt.pause(2)