Migrate visualization layer from Plotly to matplotlib#64
Closed
OmerShubi wants to merge 1 commit into
Closed
Conversation
Replace the entire figure layer (scanpath, heatmaps, comparison, animation, research charts) with matplotlib. Static export (PNG/SVG/PDF) and the GIF/MP4 animation rasterizer are now fully in-process — no Kaleido, no headless Chrome, no chromium system package. The true-to-scale word labels are preserved (validated at the documented ~0.28 font-to-box ratio). - New mpl_render.py: render DPI, px<->pt unit conversions, Plotly-compatible colour/colorscale/dash parsing, exact-pixel figure scaffolding. - plots.py builders return matplotlib Figures; make_scanpath_animation returns a ScanpathAnimation (FuncAnimation + an on-screen to_jshtml interactive player). - tabs.py renders spatial plots as a fixed-size inline SVG uniformly CSS-scaled to the column (true-to-scale); research charts via st.pyplot. - export.py / api.save_figure: savefig dispatch; HTML is a self-contained SVG page; animations export as the to_jshtml player. - Drop plotly + kaleido deps, add matplotlib; remove packages.txt (chromium). - Rewrite the figure-coupled tests to assert matplotlib artists (new tests/mpl_helpers.py); full suite green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the entire visualization layer (scanpath, heatmaps, comparison, animation, and the research charts) with matplotlib. The biggest practical win: static export (PNG/SVG/PDF) and the GIF/MP4 animation rasterizer are now fully in-process — no Kaleido, no headless Chrome, no
chromiumsystem package. The hard-won true-to-scale word labels are preserved and validated at the documented ~0.28 font-to-box ratio.Net: 33 files, +2893/−3104 — the migration removed more code than it added (Plotly's frame-masking/slider/updatemenus machinery and the Kaleido warm-server logic are gone).
What changed
scanpath_studio/mpl_render.py— the rendering foundation: a fixed render DPI, screen-px↔point unit conversions, Plotly-compatible colour / colorscale / dash parsing (soconstants.pyand saved plot configs are untouched), and exact-pixel figure scaffolding.plots.py— every builder returns a matplotlibFigure;make_scanpath_animationreturns a newScanpathAnimationdataclass. The true-to-scale text math is unchanged; saccades are a singleLineCollection(preserves the old one-trace perf bound).tabs.pyrender layer — spatial plots embed as a fixed-size inline SVG, uniformly CSS-scaled to the column (the true-to-scale trick, minus the Plotly.js CDN); the animation embeds theto_jshtmlinteractive player (play/pause/scrub); research charts usest.pyplot.animation_export.py— keeps the GIF/MP4 encode half verbatim; only the Kaleido frame rasterizer is swapped for matplotlibsavefig.export.py/api.save_figure—savefigdispatch for PNG/SVG/PDF; HTML is now a self-contained SVG page; animations export as theto_jshtmlplayer.matplotlibin,plotly+kaleidoout;packages.txt(chromium) deleted. Docs / CHANGELOG / AGENTS / CLAUDE.md updated.tests/mpl_helpers.pydocuments the artist-label contract).Notable behaviour
imageio[ffmpeg]); animation export is much faster (no ~10s Chrome cold start).facecolors="none"(now an explicit transparent RGBA). Saccade-direction arrows now render as proper arrowheads (data-unit quiver width) instead of blobs.Verification
ruff format+ruff checkclean.🤖 Generated with Claude Code