1 import matplotlib.pyplot
as plt
10 lines = file_content.strip().
split(
'\n')
14 if line.strip().startswith(
"join"):
17 print(
"saving plot "+title)
18 new_x =
range(len(x_values))
19 new_x = [i/(len(x_values)-1)
for i
in new_x]
20 plt.plot(x_values,y_values,
"o-")
21 plt.plot(new_x,y_values,
"o-")
23 plt.savefig(title+
".png",format=
"png")
28 if line.strip().startswith(
"title"):
29 title = line.split(
'"')[1]
31 title = file_name+
"_dim"+title[1]
39 if len(values) == 2
and all(
is_float(v)
for v
in values):
41 x_values.append(
float(values[0]))
42 y_values.append(
float(values[1]))
54 if __name__ ==
'__main__':
55 import sys, os, argparse
61 parser = argparse.ArgumentParser(description=
"Parse file and extract x, y values and title.")
64 parser.add_argument(
'filename', type=str, help=
'The path to the file to be parsed.')
67 args = parser.parse_args()
71 with open(args.filename,
'r')
as file:
72 file_content = file.read()
75 except FileNotFoundError:
76 print(f
"File {args.filename} not found. Please provide a valid file.")