Skip to main content

Interactive Figure

This package helps students learn the basics of Python, Matplotlib and set up reaction time experiments (visual search task, Stroop task, etc.). For a more accurate timing environment refer to e.g. PsychoPy.

This is currently used at the University of Amsterdam (UvA) in the courses Introduction to Python Programming for Neuroscientists and Experimentatie - Inleiding Programmeren.

Development and packaging are managed with uv.

Installation

Requires Python 3.11 or newer. To add the package to a uv project:

uv add interactive-figure

You can also install it with pip:

pip install interactive-figure

Usage

import interactive_figure as ifig

ifig.create()
# Wait until user input is received.
ifig.wait_for_interaction()
key = ifig.get_last_key_press()
print(f"Pressed key: {key}")
ifig.close()

Each edge of the frame can be hidden independently. For example, to keep only the bottom and left edges:

ifig.create(hide_top_frame=True, hide_right_frame=True)

The four options are hide_top_frame, hide_right_frame, hide_bottom_frame, and hide_left_frame, all defaulting to False. Set all four to True to hide the entire frame. Axis labels are controlled separately with hide_x_labels and hide_y_labels. Frame options are reapplied when ifig.clear() is called.

Demos can be found in the demo folder on GitHub.

Limitations

  • Waiting for user input will not work in Jupyter Notebooks and the interactive interpreter due to the way Matplotlib handles events. Only a standalone script with an interactive figure correctly captures user input events in an event loop.
  • Automated testing is hard since tests should cover multiple backends (macosx, QtAgg, Tkgg) on multiple platforms (Windows, macOS, Linux). Tips are very welcome!

Development

Install uv, then run these commands from the repository root:

# Create the project environment and install development tools.
uv sync

# Run a demo (requires a graphical desktop).
uv run python demo/usage.py

# Run the unit tests without opening GUI windows.
uv run pytest

# Check formatting, lint, and types.
uv run black --check --diff .
uv run ruff check .
uv run mypy src/interactive_figure

# Install the docs dependencies and build the HTML documentation.
./generate_docs.sh
# Or run Sphinx directly.
uv run --group docs sphinx-build -b html docs_source docs

# Format and fix lint issues.
uv run black .
uv run ruff check --fix .

uv manages the project environment in .venv; uv run uses it automatically without manual activation. If your shell has another virtual environment activated, run deactivate or open a fresh terminal before using uv.

The dev dependency group includes the lint tools and pytest from the test group. Documentation dependencies are in the separate docs group. Commit uv.lock to keep development dependencies reproducible.

Releases

The package version is maintained in pyproject.toml, and packages are built with uv_build. For example, to release version 0.6.0:

# Set the next release version.
uv version 0.6.0

# Build a wheel and source distribution.
uv build

# Publish this release to PyPI using a PyPI API token.
# Set UV_PUBLISH_TOKEN in your environment before running this command.
uv publish dist/interactive_figure-0.6.0*

Use the chosen release version in the upload filename pattern so only that release's artifacts are published.

Metadata

Release files for interactive-figure 0.6.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for interactive-figure 0.6.5
File Size Uploaded Provenance Actions
interactive_figure-0.6.5.tar.gz 7.5 kB Without provenance Details for interactive_figure-0.6.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for interactive-figure 0.6.5
File Interpreter ABI Platform Actions
interactive_figure-0.6.5-py3-none-any.whl Python 3 none any Details for interactive_figure-0.6.5-py3-none-any.whl

Total release size: 15.7 kB

Release files / interactive_figure-0.6.5.tar.gz

Download URL interactive_figure-0.6.5.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7d21257a1e36f273df6dc484c7351b020dd5d731ec095e9256b1002cf1b7a60b
BLAKE2b-256 checksum
How to use checksums
de74f522178207a10d729deb6c28af471ea89536c916972e69fe7d9149562e27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / interactive_figure-0.6.5-py3-none-any.whl

Download URL interactive_figure-0.6.5-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac09935a1a8011df2818824bd69a621efa9d4f750739d681f5ffa03b1fea5157
BLAKE2b-256 checksum
How to use checksums
a8d67573003d3a41b4e4da04c724615d0fc322a6d725f79cbc89d18abcd81a5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for interactive-figure 0.6.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page