-
Notifications
You must be signed in to change notification settings - Fork 16
/
draw_chart.py
39 lines (34 loc) · 1.02 KB
/
draw_chart.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
32
33
34
35
36
37
38
39
import os
import plotly.plotly as py
import plotly.graph_objs as go
import plotly.io as pio
def draw_chart(scatter_x, scatter_y, line_x, line_y):
marker_opts = dict(
name = 'Individual Reward',
x = scatter_x,
y = scatter_y,
mode = 'markers',
marker = {
'size': 2
}
)
marker_trace = go.Scatter(**marker_opts)
line_opts = dict(
name = 'Mean Reward',
x = line_x,
y = line_y,
mode = 'lines'
)
line_trace = go.Scatter(**line_opts)
data = [marker_trace, line_trace]
fig = go.Figure(data=data)
log_layout = go.Layout(
yaxis = {
'type': 'log',
'autorange': True
}
)
fig_log = go.Figure(data=data, layout=log_layout)
pio.orca.config.executable = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'node_modules', 'orca', 'bin', 'orca.js')
pio.write_image(fig, 'fig.svg', width=1600, height=800)
pio.write_image(fig_log, 'fig-log.svg', width=1600, height=800)