Created
May 30, 2025 11:54
-
-
Save kenenbek/ef0e3e786a1cb939ce123cbaa25bd410 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import matplotlib.pyplot as plt | |
# Load the DataFrame from the CSV file | |
csv_file_real = "real_deperson_13.csv" | |
df_real = pd.read_csv(csv_file_real) | |
csv_file_test = "test_deperson_13_files_5.csv" | |
df_test = pd.read_csv(csv_file_test) | |
# Create the plot | |
plt.figure(figsize=(15, 8)) | |
# Plot each segment and check for intersections | |
for i, row_real in df_real.iterrows(): | |
y_level = i | |
real_start, real_end = row_real['start'], row_real['end'] | |
# Add text label for real data | |
plt.text(real_end + 0.1, y_level+0.4, row_real['path'], | |
verticalalignment='center', fontsize=8) | |
# Find corresponding test row | |
if i < len(df_test): | |
row_test = df_test.iloc[i] | |
test_start, test_end = row_test['start'], row_test['end'] | |
# Check for overlap | |
if not (real_end < test_start or test_end < real_start): | |
# There is overlap - draw pink segment | |
overlap_start = max(real_start, test_start) | |
overlap_end = min(real_end, test_end) | |
plt.hlines(y=y_level, xmin=overlap_start, xmax=overlap_end, | |
color='pink', linewidth=3, alpha=1.0) | |
# Draw original segments | |
plt.hlines(y=y_level, xmin=real_start, xmax=real_end, | |
color='blue', linewidth=3, alpha=0.5) | |
plt.hlines(y=y_level, xmin=test_start, xmax=test_end, | |
color='red', linewidth=3, alpha=0.5) | |
# Create empty lines for legend | |
plt.plot([], [], color='blue', linewidth=3, alpha=0.5, label='Real') | |
plt.plot([], [], color='red', linewidth=3, alpha=0.5, label='Test') | |
plt.plot([], [], color='pink', linewidth=3, label='Overlap') | |
plt.grid(True, linestyle='--', alpha=0.7) | |
plt.xlabel('Time (seconds)') | |
plt.ylabel('Segment Number') | |
plt.title('Audio Segments Timeline') | |
plt.yticks(range(len(df_real))) | |
plt.legend() | |
# Add some padding to the right to accommodate the text labels | |
plt.margins(x=0.2) | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment