Skip to content

Instantly share code, notes, and snippets.

@padenot
Created February 17, 2025 17:28
Show Gist options
  • Save padenot/2a58ac267ec24ef0d2fcfeb3e5592c9d to your computer and use it in GitHub Desktop.
Save padenot/2a58ac267ec24ef0d2fcfeb3e5592c9d to your computer and use it in GitHub Desktop.
import pandas as pd
import matplotlib.pyplot as plt
import json
import numpy as np
import sys
# Load data from JSON file
with open(sys.argv[1], 'r') as f:
data = json.load(f)
df = pd.DataFrame(data, columns=["Input Rate", "Output Rate", "Block Size", "MSE", "Amplitude", "Phase"])
# Compute resampling ratio
df["Resampling Ratio"] = df["Input Rate"] / df["Output Rate"]
# Apply log scale to MSE for better visualization
plt.figure(figsize=(10, 6))
sc = plt.scatter(df["Resampling Ratio"], df["Block Size"], c=np.log10(df["MSE"]), cmap='viridis', marker='o')
# Labels and title
plt.xlabel("Resampling Ratio (Input Rate / Output Rate)")
plt.ylabel("Block Size (frames)")
plt.title("Scatter Plot of Resampling Ratio vs Block Size with Log-Scaled MSE Coloring " + sys.argv[1])
# Color bar for log-scaled MSE values
cbar = plt.colorbar(sc)
cbar.set_label("Log10(Mean Squared Error)")
plt.grid(True)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment