Spaces:
Build error
Build error
Download run_experiment.py from ulas742/spatial-audio-study: direct link, hf CLI and curl.
- Browser
- Download file 1.51 kB
-
https://huggingface.co/spaces/ulas742/spatial-audio-study/resolve/main/run_experiment.py
- Command line
-
hf download hf://spaces/ulas742/spatial-audio-study/run_experiment.py
-
curl -L -o run_experiment.py https://huggingface.co/spaces/ulas742/spatial-audio-study/resolve/main/run_experiment.py
1.51 kB
| from hrtf_vs_pitch_sonifier import * | |
| normal_color = 'black' | |
| hover_color = 'blue' | |
| # Store original colors to reset them after hover | |
| fig, axes = plt.subplots(2, 2, figsize=(8, 8)) | |
| def is_inside_axes(event, ax): | |
| return ax.get_position().contains(event.x, event.y) | |
| # Event handler for mouse movement | |
| def on_hover(event): | |
| for ax in axes: | |
| # Check if the cursor is inside the current subplot | |
| if is_inside_axes(event, ax): | |
| # Change color if inside | |
| for spine in ax.spines.values(): | |
| spine.set_color(hover_color) | |
| else: | |
| # Reset to normal color if outside | |
| for spine in ax.spines.values(): | |
| spine.set_color(normal_color) | |
| fig.canvas.draw_idle() # Update the figure | |
| def run_test(datasets, idxs, y_mode, show_correct = None): | |
| fig.canvas.mpl_connect('motion_notify_event', on_hover) | |
| for i, ax in enumerate(axes.flat): | |
| ax.scatter(datasets[idxs[i]]["x"], datasets[idxs[i]]["y"] if y_mode == "pitch" else [0] * len(datasets[idxs[i]]["x"])) | |
| ax.set_title(f"Plot {i + 1}") | |
| ax.grid(True) | |
| if show_correct is not None: | |
| for spine in ax.spines.values(): | |
| if idxs[i] == show_correct: | |
| spine.set_linewidth(2) | |
| spine.set_color("green") | |
| else: | |
| spine.set_color("red") | |
| plt.tight_layout() | |
| plt.show() | |
| y_mode = "static" | |
| run_test(datasets, [0, 2, 3, 5], y_mode) | |