{"id":19724354,"url":"https://github.com/jungerm2/matplotlib-svg-animation-writer","last_synced_at":"2025-02-27T18:49:15.452Z","repository":{"id":83530274,"uuid":"348159779","full_name":"jungerm2/Matplotlib-SVG-Animation-Writer","owner":"jungerm2","description":"A diff/patch approach to matplotlib's animation HTMLWriter","archived":false,"fork":false,"pushed_at":"2021-05-02T17:15:49.000Z","size":336,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-10T16:45:35.927Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jungerm2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-16T00:12:43.000Z","updated_at":"2021-05-02T17:15:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"48e03018-4790-4a69-b2ef-67206849641d","html_url":"https://github.com/jungerm2/Matplotlib-SVG-Animation-Writer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2FMatplotlib-SVG-Animation-Writer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2FMatplotlib-SVG-Animation-Writer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2FMatplotlib-SVG-Animation-Writer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jungerm2%2FMatplotlib-SVG-Animation-Writer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jungerm2","download_url":"https://codeload.github.com/jungerm2/Matplotlib-SVG-Animation-Writer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241045669,"owners_count":19899697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T23:25:35.318Z","updated_at":"2025-02-27T18:49:15.432Z","avatar_url":"https://github.com/jungerm2.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SVGFuncAnimation\n\n### How it works:\n\nThis aims to be a drop-in replacement for matplotlib's `FuncAnimation` which works only for SVG based animations. As such,\nit's interface is greatly simplified, and it comes with its own, built-in, `HTMLWriter`-like writer. \n\nBecause it focuses solely on SVGs, the resulting html animation displays the SVG document directly instead of a \nbase64-encoded version. This allows direct manipulation of the SVG DOM which is fast and memory efficient as the whole \nframe is not needed.\n\nThis works by redrawing only individual artists instead of the whole frame. The artist redraw creates a new SVG tag \n(which can be captured with some StringIO manipulations). This new tag is then dynamically inserted into the SVG document\nby the accompanying JS script when that frame is reached. \n\nIn order to fetch the correct tag that needs to be updated, we rename every artist's GID to that artist's hash. \nThis new ID the allows us to find the correct SVG tag and keep track of all artists. \n\n### Demo:\n\nSVGFuncAnimation is much faster and more memory efficient than it's FuncAnimation counterpart:\n\n![benchmark picture](svgfuncanim_benchmark.png)\n\nPlease see [svgfuncanim](svgfuncanim.ipynb) for a quick demo, and [this](svgfuncanim_benchmark.ipynb) to see \nhow the above was generated.\n\n_*Note:*_ Currently `SVGFuncAnimation` relies on a few small tweaks in the matplotlib's SVG backend which can be found \non [my fork of matplotlib](https://github.com/jungerm2/matplotlib). I do plan on merging these if this feature gets \naccepted.\n\n### Current Limitations:\n\nThis is still a WIP, so these are subject to change, but currently, one of the main limitations of `SVGFuncAnimation` is \nthat it requires that all artists that will be drawn during the animation be present from the onset. That is, the creation \nof new artists within the user-provided update function is not yet supported.\n\nSome artists, like `Text` artists might also be blank/empty and thus not be drawn when the animation initializes. For now, \na good workaround is to make sure they are initialized with non-emtpy text (such as a space).\n\n# HTMLDiffWriter\n\nAn experimental `HTMLWriter` for matplotlib animations that stores only the first frame as well as the frame \ndeltas/diffs of consecutive frames. Frames are therefore computed on the fly which should enable huge memory savings \nbut might be slow. \n\nThis was originally intended for use only with animations that use the SVG frame format, but because diffing is done \non the base64-encoded frames, this also applies to other formats (although the filesize might not reduce as much).\n\nSee [diffwriter](diffwriter.ipynb) for a quick demo.\n\n---\n\nSee [this matplotlib issue](https://github.com/matplotlib/matplotlib/issues/19694) for more.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjungerm2%2Fmatplotlib-svg-animation-writer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjungerm2%2Fmatplotlib-svg-animation-writer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjungerm2%2Fmatplotlib-svg-animation-writer/lists"}