Skip to content

Remove matplotlib display usage from plot_spectrogram#471

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/generate-simple-image-output
Draft

Remove matplotlib display usage from plot_spectrogram#471
Copilot wants to merge 6 commits intomainfrom
copilot/generate-simple-image-output

Conversation

Copy link

Copilot AI commented Feb 14, 2026

plot_spectrogram() in spectrogram_utils.py was calling plt.show() to display plots interactively when no output path was provided. This breaks headless environments and violates the principle of generating images without display.

Changes

  • Removed interactive display: Eliminated plt.show() call, always saves to file
  • Force non-GUI backend: Added matplotlib.use('Agg') at module import
  • Temporary file handling: When plotpath=None, creates temp file with NamedTemporaryFile(delete=False)
  • API change: Return signature changed from ims to (ims, plotpath) tuple

Example

# Before - would show plot window if plotpath=None
ims = plot_spectrogram('audio.wav')  # plt.show() called

# After - always saves, returns path
ims, path = plot_spectrogram('audio.wav')  # temp file created
ims, path = plot_spectrogram('audio.wav', 'output.png')  # explicit path

Breaking change: Function signature modified. Verified unused in codebase.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 5 commits February 14, 2026 19:53
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Co-authored-by: hackolite <826027+hackolite@users.noreply.github.com>
Copilot AI changed the title [WIP] Generate a simple image for data display Remove matplotlib display usage from plot_spectrogram Feb 14, 2026
Copilot AI requested a review from hackolite February 14, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants