https://github.com/stsievert/python-drawnow

MATLAB-like drawnow to easily update a figure

https://github.com/stsievert/python-drawnow

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

python visualization
Last synced: 6 months ago · JSON representation

Repository

MATLAB-like drawnow to easily update a figure

Basic Info
  • Host: GitHub
  • Owner: stsievert
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 2.92 MB
Statistics
  • Stars: 105
  • Watchers: 10
  • Forks: 15
  • Open Issues: 2
  • Releases: 0
Topics
python visualization
Created almost 12 years ago · Last pushed almost 6 years ago
Metadata Files
Readme

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:

image0

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:

  1. Run pip install drawnow.
  2. 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

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 82
  • Total Committers: 4
  • Avg Commits per committer: 20.5
  • Development Distribution Score (DDS): 0.183
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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

  • Versions: 18
  • Dependent Packages: 3
  • Dependent Repositories: 39
  • Downloads: 1,199 Last month
  • Docker Downloads: 0
Rankings
Dependent packages count: 2.3%
Dependent repos count: 2.3%
Docker downloads count: 3.6%
Average: 5.2%
Downloads: 6.9%
Stargazers count: 6.9%
Forks count: 9.1%
Maintainers (2)
Last synced: 6 months ago

Dependencies

setup.py pypi
  • matplotlib >=1.5