https://github.com/stsievert/python-drawnow
MATLAB-like drawnow to easily update a figure
Science Score: 10.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
1 of 4 committers (25.0%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.2%) to scientific vocabulary
Keywords
Repository
MATLAB-like drawnow to easily update a figure
Basic Info
Statistics
- Stars: 105
- Watchers: 10
- Forks: 15
- Open Issues: 2
- Releases: 0
Topics
Metadata Files
README.md
drawnow for matplotlib
The scientific community often runs iterative code, often in the form of
simulation. It's often useful to see the results after each iteration.
Accordingly, MATLAB® has a nice feature that allows you to update the
figure, drawnow. This repo brings the same feature to Python's
matplotlib, with some extras.
Example:

This is shown with imshow, but python-drawnow allows updates of any
figure.
Usage:
``` python
complete implementation of script found in test/test.py
from pylab import * from drawnow import drawnow, figure
if global namespace, import plt.figure before drawnow.figure
def approx(x, k): """Approximate x with k singular values""" ...
figure(figsize=(7, 7/2)) def draw_fig(): subplot(1, 2, 1) imshow(x)
subplot(1, 2, 2)
imshow(x_hat)
#show()
x = imread('test-data/mandrill.png').mean(axis=2) kvalues = around(logspace(0, 2, num=10)) for k in kvalues: xhat = approx(x, k) drawnow(drawfig) ```
Documentation
If you want to wait for confirmation after update or the option to drop
into a debugger, call drawnow(function_to_draw_figure, confirm=True).
If you only want to show the figure once, call
drawnow(function_to_draw_figure, show_once=True). The full
documentation is included in the doc strings. Use drawnow? or
help(drawnow) to see these docs.
Jupyter/Spyder
Try running the folloowing code in a Jupyter input cell/in the console/etc:
%matplotlib
This will disable the Matplotlin inline mode and use the default plotting backend. For more detail, see the IPython plotting documentation.
Installation
Two options:
- Run
pip install drawnow. - Download this repository and run
python setup.py install.
Option 2 assumes a working Python installation with pip. I suggest
Anaconda's distribution: https://www.anaconda.com/distribution/ For
other options, see https://realpython.com/installing-python/.
Changes to code
This does require small changes to your code. All it should really
amount to is moving figure(); plot(...); show() inside a function; not
much.
Owner
- Name: Scott Sievert
- Login: stsievert
- Kind: user
- Website: https://stsievert.com
- Repositories: 45
- Profile: https://github.com/stsievert
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: 8 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| scottsievert | s****1@u****u | 67 |
| Scott Sievert | g****b@s****m | 11 |
| Scott Sievert | s****t@i****m | 2 |
| Scott Sievert | s****t@s****m | 2 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 7 months ago
All Time
- Total issues: 12
- Total pull requests: 1
- Average time to close issues: about 1 month
- Average time to close pull requests: 11 minutes
- Total issue authors: 12
- Total pull request authors: 1
- Average comments per issue: 5.58
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- rjsdotorg (1)
- jsanchezq1 (1)
- bogbasic (1)
- sripetta (1)
- rjollos (1)
- jonasstoetzel (1)
- wangwuqi (1)
- afvincent (1)
- nosratullah (1)
- NauticalMile64 (1)
- sieumap43 (1)
- jue-jiang (1)
Pull Request Authors
- stsievert (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 1,199 last-month
- Total dependent packages: 3
- Total dependent repositories: 39
- Total versions: 18
- Total maintainers: 2
pypi.org: drawnow
MATLAB-like drawnow
- Homepage: https://github.com/stsievert/python-drawnow
- Documentation: https://drawnow.readthedocs.io/
- License: MIT License
-
Latest release: 0.72.5
published almost 6 years ago
Rankings
Maintainers (2)
Dependencies
- matplotlib >=1.5