#! /usr/bin/python3
import sys
import matplotlib.pyplot as plt

if len(sys.argv) == 1 or len(sys.argv) > 2:
    print("usage:", sys.argv[0], "<filename>")
    exit()

# open file and remove newlines. readlines is okay b/c
# the input file shouldn't be thaaaat big
f=open(sys.argv[1])
lines = [line.strip() for line in f.readlines()]
f.close()

# first column defines the inputs
impl_domain = [float(x.split(" ")[0]) for x in lines[3:]]
impl_range  = [float(x.split(" ")[1]) for x in lines[3:]]
plt.loglog(impl_domain, impl_range, '-')
impl_range  = [float(x.split(" ")[2]) for x in lines[3:]]
plt.loglog(impl_domain, impl_range, '-')
impl_range  = [float(x.split(" ")[3]) for x in lines[3:]]
plt.loglog(impl_domain, impl_range, '-')
impl_range  = [float(x.split(" ")[4]) for x in lines[3:]]
plt.loglog(impl_domain, impl_range, '-')
impl_range  = [float(x.split(" ")[5]) for x in lines[3:]]
plt.loglog(impl_domain, impl_range, '-')
impl_range  = [float(x.split(" ")[6]) for x in lines[3:]]
plt.loglog(impl_domain, impl_range, '-')



# make a .png from the .dat file
#new_filename = sys.argv[1]
#dot = new_filename.index(".")
#new_filename = new_filename[0:dot] + ".png"
#plt.savefig(new_filename, dpi=300, bbox_inches='tight')
plt.grid()
plt.show()



