import pandas as pd
import matplotlib.pyplot as plt

# 文件路径（请根据实际情况修改）
file1 = "42409194_959171YT3252518@R04_7000_ST11210_TestCurve_20260420183238_NG.csv"
file2 = "42409194_959171YT4058793@R04_7000_ST11210_TestCurve_20260420194020_NG.csv"

# 读取数据
df1 = pd.read_csv(file1)
df2 = pd.read_csv(file2)

# 方法一：分别绘制两张独立图
# 图1
plt.figure(figsize=(10, 6))
plt.plot(df1['Voltage'], df1['Current'], 'b-o', markersize=3, linewidth=1, alpha=0.7)
plt.xlabel('Voltage (V)')
plt.ylabel('Current (mA)')
plt.title('Insulation Withstand Test Curve - File 1 (NG)')
plt.grid(True, linestyle='--', alpha=0.6)
plt.tight_layout()
plt.show()

# 图2
plt.figure(figsize=(10, 6))
plt.plot(df2['Voltage'], df2['Current'], 'r-o', markersize=3, linewidth=1, alpha=0.7)
plt.xlabel('Voltage (V)')
plt.ylabel('Current (mA)')
plt.title('Insulation Withstand Test Curve - File 2 (NG)')
plt.grid(True, linestyle='--', alpha=0.6)
plt.tight_layout()
plt.show()

# 方法二：并排显示两张子图（便于对比）
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 5))
ax1.plot(df1['Voltage'], df1['Current'], 'b-o', markersize=2, linewidth=0.8, alpha=0.7)
ax1.set_xlabel('Voltage (V)')
ax1.set_ylabel('Current (mA)')
ax1.set_title('File 1 (2026-04-20 18:32:38)')
ax1.grid(True, linestyle='--', alpha=0.5)

ax2.plot(df2['Voltage'], df2['Current'], 'r-o', markersize=2, linewidth=0.8, alpha=0.7)
ax2.set_xlabel('Voltage (V)')
ax2.set_ylabel('Current (mA)')
ax2.set_title('File 2 (2026-04-20 19:40:20)')
ax2.grid(True, linestyle='--', alpha=0.5)

plt.suptitle('Insulation Withstand Test Curves (Voltage vs Current)', fontsize=14)
plt.tight_layout()
plt.show()