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

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.1
File Size Uploaded
interactive_figure-0.6.1.tar.gz 7.0 kB Details

Built distribution (wheel)

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

Total release size: 14.7 kB

Release files / interactive_figure-0.6.1.tar.gz

Download URL interactive_figure-0.6.1.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bed537857a4f0ca19e022358a7372abf9e047fdcdd0426ef9875768cec6158f0
BLAKE2b-256 checksum
How to use checksums
27bd666138b8154ad0eac34f84d5c0a6c58cccca5d8055bfcb297c333c63a984
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.1-py3-none-any.whl

Download URL interactive_figure-0.6.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
382af69b99e8c3185b39b328e46883ce2e73bd4212fdd8d15948e46a3d49931e
BLAKE2b-256 checksum
How to use checksums
c9046c3bc562c1392ca5084d95b9b68e63483e073d0cfc9254a7cea3e5d327cd
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 history Release notifications | RSS feed

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

This release

0.6.1 This release

2 release files

0.6.0

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