1+ # ploter for the Live_plots_Temperature_dependendent_V
2+ import pandas as pd
3+ import matplotlib .pyplot as plt
4+ # TODO: Investigate and fix matplotlib.animation ModuleNotFoundError.
5+ # from matplotlib.animation import FuncAnimation
6+ from tkinter import filedialog
7+ import tkinter as tk
8+
9+
10+ def live_plot_from_csv (selected_file ):
11+ """
12+ Creates a live-updating plot from a specified CSV file.
13+ This is currently a no-op due to ModuleNotFoundError with matplotlib.animation.
14+ """
15+ print (f"Skipping live plot for { selected_file } due to environment issue." )
16+ # The original implementation for live plotting using FuncAnimation is commented out.
17+ # To re-enable, uncomment the FuncAnimation import and the code below.
18+
19+ # plt.style.use('fivethirtyeight')
20+ # fig, axs = plt.subplots(3, 1, figsize=(9, 12))
21+
22+ # def animate(i):
23+ # data = pd.read_csv(selected_file)
24+ # x = data['Time (s)']
25+ # y1 = data['Temperature (K)']
26+ # y2 = data['Voltage (V)']
27+
28+ # for ax in axs:
29+ # ax.clear()
30+
31+ # axs[0].plot(x, y1, label='T', color='b', linewidth=0.8)
32+ # axs[0].scatter(x, y1, color='b')
33+ # axs[0].set_title('Temperature vs Time', fontsize=13)
34+ # axs[0].set_xlabel('Time (s)', fontsize=13)
35+ # axs[0].set_ylabel('Temperature (K)', fontsize=13)
36+ # axs[0].legend(loc='upper left')
37+
38+ # axs[1].plot(x, y2, label='V', color='g', linewidth=0.8)
39+ # axs[1].scatter(x, y2, color='g')
40+ # axs[1].set_title('Voltage vs Time', fontsize=13)
41+ # axs[1].set_xlabel('Time (s)', fontsize=13)
42+ # axs[1].set_ylabel('Voltage (V)', fontsize=13)
43+ # axs[1].legend(loc='upper left')
44+
45+ # axs[2].plot(y1, y2, label='V vs T', color='r', linewidth=0.8)
46+ # axs[2].scatter(y1, y2, color='r')
47+ # axs[2].set_title('Voltage vs Temperature', fontsize=13)
48+ # axs[2].set_xlabel('Temperature (K)', fontsize=13)
49+ # axs[2].set_ylabel('Voltage (V)', fontsize=13)
50+ # axs[2].legend(loc='upper left')
51+
52+ # ani = FuncAnimation(fig, animate, interval=1000, cache_frame_data=False)
53+ # plt.tight_layout()
54+ # plt.show()
55+
56+
57+ def main ():
58+ """Main function to select a file and start the plotting."""
59+ # Use tkinter to create a file selection dialog
60+ root = tk .Tk ()
61+ root .withdraw () # Hide the root window
62+ selected_file = filedialog .askopenfilename (
63+ title = "Select a CSV data file" ,
64+ filetypes = (("CSV files" , "*.csv" ),
65+ ("Data files" , "*.dat" ),
66+ ("All files" , "*.*" ))
67+ )
68+
69+ if not selected_file :
70+ print ("No file selected. Exiting." )
71+ return
72+
73+ print (f"Selected file: { selected_file } " )
74+ live_plot_from_csv (selected_file )
75+
76+
77+ if __name__ == '__main__' :
78+ main ()
0 commit comments