CSVVisualizer.py aktualisiert

self.ax.margins(x=0) tells matplotlib not to add padding on the x-axis.
(Chat)
This commit is contained in:
Jan 2025-05-26 21:07:08 +02:00
parent e034150dc1
commit f06ccc2e6a

View File

@ -77,6 +77,7 @@ class CSVVisualizer:
try: try:
# First detect problematic lines # First detect problematic lines
self.status_var.set("Datei geladen prüfe Zeilen…") self.status_var.set("Datei geladen prüfe Zeilen…")
self.root.update_idletasks()
good_lines = [] good_lines = []
with open(filepath, 'r') as f: with open(filepath, 'r') as f:
reader = csv.reader(f) reader = csv.reader(f)
@ -98,10 +99,12 @@ class CSVVisualizer:
if not good_lines: if not good_lines:
messagebox.showwarning("Warnung", "Keine gültigen Datenzeilen gefunden.") messagebox.showwarning("Warnung", "Keine gültigen Datenzeilen gefunden.")
self.status_var.set("Keine gültigen Daten") self.status_var.set("Keine gültigen Daten")
self.root.update_idletasks()
return return
# Now read only valid lines # Now read only valid lines
self.status_var.set("Verarbeite gültige Zeilen…") self.status_var.set("Verarbeite gültige Zeilen…")
self.root.update_idletasks()
self.df = pd.read_csv( self.df = pd.read_csv(
filepath, filepath,
skiprows=lambda x: x not in good_lines and x != 0, # keep header skiprows=lambda x: x not in good_lines and x != 0, # keep header
@ -121,6 +124,7 @@ class CSVVisualizer:
self.file_label.config(text=os.path.basename(filepath)) self.file_label.config(text=os.path.basename(filepath))
self.status_var.set(f"Loaded: {len(self.df)} valid measurements") self.status_var.set(f"Loaded: {len(self.df)} valid measurements")
self.root.update_idletasks()
self.update_plot() self.update_plot()
except Exception as e: except Exception as e:
@ -144,6 +148,7 @@ class CSVVisualizer:
# Spannung plotten # Spannung plotten
self.ax.plot(df_clean["Relative_Time(s)"], df_clean["Voltage(V)"], self.ax.plot(df_clean["Relative_Time(s)"], df_clean["Voltage(V)"],
label="Voltage (V)", color="black", linewidth=1.5) label="Voltage (V)", color="black", linewidth=1.5)
self.ax.margins(x=0)
# Phasen als farbige Hintergründe # Phasen als farbige Hintergründe
start_idx = 0 start_idx = 0