-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper.py
31 lines (24 loc) · 957 Bytes
/
helper.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
import plotly.graph_objs as go
from plotly.subplots import make_subplots
import IPython.display as ipyd
# Create a Plotly figure
def create_figure(scores, mean_scores):
fig = make_subplots(rows=1, cols=1)
# Add the 'Scores' trace
fig.add_trace(go.Scatter(x=list(range(1, len(scores) + 1)), y=scores, name='Scores'))
# Add the 'Mean Scores' trace
fig.add_trace(go.Scatter(x=list(range(1, len(mean_scores) + 1)), y=mean_scores, name='Mean Scores'))
# Set the layout
fig.update_layout(
title='Training...',
xaxis_title='Number of Games',
yaxis_title='Score',
yaxis_range=[0, max(scores + mean_scores)],
)
return fig
def plot(scores, mean_scores):
# Create the Plotly figure
fig = create_figure(scores, mean_scores)
# Display the figure in Jupyter Notebook
ipyd.display(ipyd.HTML('<script src="/static/components/requirejs/require.js"></script>'))
ipyd.display(fig)