Skip to content

Instantly share code, notes, and snippets.

@shipof123
Created May 19, 2019 22:29
Show Gist options
  • Save shipof123/1efc7f2a0be5a679aa0901eb6e9d6fc4 to your computer and use it in GitHub Desktop.
Save shipof123/1efc7f2a0be5a679aa0901eb6e9d6fc4 to your computer and use it in GitHub Desktop.
#!/bin/python
import plotly as pl
import plotly.graph_objs as go
from sys import argv
crx = [] # [0]
mut = [] # [1]
#gav= [] # [2]
avg = [] # [3]
"""gst = [] # [4]
std = [] # [5]
gmn = [] # [6]
min = [] # [7]
gmx = [] # [8]"""
max = [] # [3] # [9]
i = open(argv[1], "r")
for line in i.readlines():
if argv[3] == "pruned":
(_cx, _mu, _avg, _max) = line.split()
else:
(_cx, _mu, _ga, _avg, _gs, _s, _gm, _m, _gmx, _max) = line.split()
crx.append(_cx)
mut.append(_mu)
avg.append(_avg)
#std.append(_std)
#min.append(_min)
max.append(_max)
crx_avg = go.Scatter(
x = crx,
y = avg,
name = "avg - crx",
line = dict(
color = 'rgb(255, 0, 0)'
)
)
mut_avg = go.Scatter(
x = mut,
y = avg,
name = "avg - mut",
line = dict(
color = 'rgb(255, 75, 0)'
)
)
# Should I map STD?
"""tr_std = go.Scatter(
x = crx,
y = std,
name = "std",
line = dict(
color = 'rgb(0, 255, 0)'
)
)"""
crx_max = go.Scatter(
x = crx,
y = max,
name = "max - crx",
line = dict(
color = 'rgb(0, 0, 255)'
)
)
mut_max = go.Scatter(
x = mut,
y = max,
name = "max - mut",
line = dict(
color = 'rgb(0, 75, 255)'
)
)
if argv[4] == 'crx':
data = [crx_avg, crx_max]
elif argv[4] == 'mut':
data = [mut_avg, mut_max]
else:
data = [crx_avg, mut_avg, crx_max, mut_max]
layout = dict(title = argv[3],
xaxis = dict(title = "Rate of Crossover"),
yaxis = dict(title = "Total Benefit of Pack (Fitness)")
)
fig = dict(data=data, layout=layout)
pl.offline.plot(fig, filename=argv[2], auto_open=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment