{"id":15441317,"url":"https://github.com/stsievert/python-drawnow","last_synced_at":"2025-06-28T19:32:17.907Z","repository":{"id":15943836,"uuid":"18686146","full_name":"stsievert/python-drawnow","owner":"stsievert","description":"MATLAB-like drawnow to easily update a figure","archived":false,"fork":false,"pushed_at":"2020-05-17T02:21:07.000Z","size":3059,"stargazers_count":106,"open_issues_count":2,"forks_count":15,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-06-09T02:09:36.061Z","etag":null,"topics":["python","visualization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stsievert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-11T19:30:12.000Z","updated_at":"2024-10-27T01:04:06.000Z","dependencies_parsed_at":"2022-09-26T20:41:20.121Z","dependency_job_id":null,"html_url":"https://github.com/stsievert/python-drawnow","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/stsievert/python-drawnow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stsievert%2Fpython-drawnow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stsievert%2Fpython-drawnow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stsievert%2Fpython-drawnow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stsievert%2Fpython-drawnow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stsievert","download_url":"https://codeload.github.com/stsievert/python-drawnow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stsievert%2Fpython-drawnow/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262484133,"owners_count":23318400,"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":["python","visualization"],"created_at":"2024-10-01T19:20:00.761Z","updated_at":"2025-06-28T19:32:17.885Z","avatar_url":"https://github.com/stsievert.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--XXX: UPDATE WITH--\u003e\n\u003c!--python setup.py build--\u003e\n\u003c!--python setup.py sdist upload--\u003e\n\n`drawnow` for matplotlib\n========================\n\nThe scientific community often runs iterative code, often in the form of\nsimulation. It's often useful to see the results after each iteration.\nAccordingly, MATLAB® has a nice feature that allows you to update the\nfigure, `drawnow`. This repo brings the same feature to Python's\nmatplotlib, with some extras.\n\nExample:\n\n![image0](test-data/test.gif)\n\nThis is shown with `imshow`, but python-drawnow allows updates of any\nfigure.\n\nUsage:\n\n``` python\n# complete implementation of script found in test/test.py\nfrom pylab import *\nfrom drawnow import drawnow, figure\n# if global namespace, import plt.figure before drawnow.figure\n\ndef approx(x, k):\n    \"\"\"Approximate x with k singular values\"\"\"\n    ...\n\nfigure(figsize=(7, 7/2))\ndef draw_fig():\n    subplot(1, 2, 1)\n    imshow(x)\n\n    subplot(1, 2, 2)\n    imshow(x_hat)\n    #show()\n\nx = imread('test-data/mandrill.png').mean(axis=2)\nk_values = around(logspace(0, 2, num=10))\nfor k in k_values:\n    x_hat = approx(x, k)\n    drawnow(draw_fig)\n```\n\nDocumentation\n=============\n\nIf you want to wait for confirmation after update or the option to drop\ninto a debugger, call `drawnow(function_to_draw_figure, confirm=True)`.\n\nIf you only want to show the figure once, call\n`drawnow(function_to_draw_figure, show_once=True)`. The full\ndocumentation is included in the doc strings. Use `drawnow?` or\n`help(drawnow)` to see these docs.\n\nJupyter/Spyder\n==============\n\nTry running the folloowing code in a Jupyter input cell/in the\nconsole/etc:\n\n```\n%matplotlib\n```\n\nThis will disable the Matplotlin inline mode and use the default\nplotting backend. For more detail, see the [IPython plotting\ndocumentation](https://ipython.readthedocs.io/en/stable/interactive/plotting.html#id1).\n\nInstallation\n============\n\nTwo options:\n\n1.  Run `pip install drawnow`.\n2.  Download this repository and run `python setup.py install`.\n\nOption 2 assumes a working Python installation with `pip`. I suggest\nAnaconda's distribution: \u003chttps://www.anaconda.com/distribution/\u003e For\nother options, see \u003chttps://realpython.com/installing-python/\u003e.\n\nChanges to code\n---------------\n\nThis does require *small* changes to your code. All it should really\namount to is moving `figure(); plot(...); show()` inside a function; not\nmuch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstsievert%2Fpython-drawnow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstsievert%2Fpython-drawnow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstsievert%2Fpython-drawnow/lists"}