Skip to main content

Interactive Figure

This package serves for students to learn the basics of Python, Matplotlib and setting up reaction time experiments (visual search task, Stroop task, etc.). For a more accurate timing environment one should 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()

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.
  • 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

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

# 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. Documentation dependencies are in the separate docs group. Commit uv.lock to keep development dependencies reproducible. There is currently no automated test suite; use the demos to check GUI behavior.

Documentation

# 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

Both commands use the existing configuration in docs_source/conf.py and write HTML to docs/.

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.0

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.0
File Size Uploaded
interactive_figure-0.6.0.tar.gz 6.8 kB Details

Built distribution (wheel)

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

Total release size: 14.3 kB

Release files / interactive_figure-0.6.0.tar.gz

Download URL interactive_figure-0.6.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c4b2333979c9451cbcd8251d44b8c6ec6b92cad8ea8fdf16fa6a0bea410b2fe3
BLAKE2b-256 checksum
How to use checksums
be056565074502cb21b8007678bfe1034cb7ed741aa1c5336910963fdd324e5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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.0-py3-none-any.whl

Download URL interactive_figure-0.6.0-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6880053d5e10553ebb3997ae9a22f99bffb3e9d20110aafc79f316f2cd1c465
BLAKE2b-256 checksum
How to use checksums
150528737c2991c60add8908503e748a17085a8fbe657a72f78a0f23feab5f50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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 history Release notifications | RSS feed

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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