From dceb6188e24f06d5bdab9a7fcbe20ca81d5d92bc Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Thu, 16 Mar 2023 10:12:46 -0400 Subject: [PATCH] [+] Data plotting --- data/plot.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 data/plot.py diff --git a/data/plot.py b/data/plot.py new file mode 100644 index 0000000..029cd09 --- /dev/null +++ b/data/plot.py @@ -0,0 +1,24 @@ +from pathlib import Path + +import plotly.graph_objs as go + +if __name__ == '__main__': + + # open the file for reading + fp = Path('piezo1md.txt') + with open(fp, 'r') as f: + lines = f.readlines() + + # parse the elapsed time and value from each line + times = [] + values = [] + for line in lines: + parts = line.strip().split(': ') + times.append(int(parts[0])) + values.append(int(parts[1])) + + # create the time-series graph + fig = go.Figure() + fig.add_trace(go.Scatter(x=times, y=values, mode='lines', name='Value')) + fig.update_layout(title=f'Time-Series Graph ({fp})', xaxis_title='Elapsed Time', yaxis_title='Value') + fig.show() \ No newline at end of file