Skip to main content

MatplotAlt

MatplotAlt is a Python library for generating and displaying matplotlib figure alt text in computational notebooks.

This is an ongoing project, so let us know if you have any feedback or feature requests on our discussion page! For more examples and evaluation of our methods, see our preprint.

Update 10/2025: also check out Py maidr for an alternative with braille and sonification options

Installation

The latest release can be installed from PyPI:

pip install matplotalt

Usage

Documentation is available at matplotalt's read-the-docs page, including examples, API reference, and other useful information.

MatplotAlt's show_with_alt function can generate and display alt text for a figure in a single line of code. Note: show_with_alt is meant to replace plt.show and will not work if Matplotlib's show is called first.

import matplotlib.pyplot as plt
from matplotalt import show_with_alt

sunshine_hours = [69, 108, 178, 207, 253, 268, \
                  312, 281, 221, 142, 72, 52]
months = ["Jan", "Feb", "Mar", "Apr", "May", "June", \
          "July", "Aug", "Sep", "Oct", "Nov", "Dec"]
plt.title("Monthly Sunshine in Seattle")
plt.barh(list(range(12)), sunshine_hours)
plt.xlabel("Average hours of sunlight")
plt.ylabel("Month")
plt.yticks(ticks=list(range(12)), labels=months)

show_with_alt(desc_level=3, methods="markdown")

The desc_level parameter controls how detailed the description is from 1 (least detail) to 3 (most) based on Lundgard and Satyanarayan, 2021.

The methods parameter controls how to display generated alt text and accepts one or a list of strings. Currently supported methods to display alt text are:

  • html: displays the last figure in html with an alt property containing the alt text.
  • markdown: display text in markdown in the current cell output.
  • new_cell: create a new (code) cell after this one containing the alt text.
  • txt_file: writes the alt text to a text file.
  • img_file: saves the last matplotlib figure with the generated description in its alt property.

If you need more control over how alt text is created or displayed, we also provide the generate_alt_text function, which returns a description for the figure as a string, and add_alt_text, which displays a given string using any of the supported methods.

There are also "API" versions of each function (show_with_api_alt, generate_api_alt_text) which generate alt text using a LLM through OpenAI and Azure APIs.

alttextify

MatplotAlt provides the alttextify command to automatically add alt text to each matplotlib figure in a IPython notebook with the same options as show_with_alt. For example,

alttextify ./examples/examples_no_alt.ipynb examples_with_alt -s html

will add alt text to each figure in the examples_no_alt.ipynb notebook through the HTML alt property without changing any of the code cells. alttextify can also be used to generate alt texts with LLMs:

alttextify ./examples/examples_no_alt.ipynb examples_with_llm_alt -k <your API key> -m gpt-4-vision-preview -us

Attribution

If you use the datasets or code provided with this work, consider citing it as below:

@article{nylund2025matplotalt,
  title={MatplotAlt: A Python Library for Adding Alt Text to Matplotlib Figures in Computational Notebooks},
  author={Nylund, Kai and Mankoff, Jennifer and Potluri, Venkatesh},
  journal={Comput. Graph. Forum},
  volume={44},
  issue={3},
  year={2025}
}

This work was supported by GitHub, Microsoft, and Google. The contents of this article were developed under a grant from the National Institute on Disability, Independent Living, and Rehabilitation Research (NIDILRR grant number 90REGE0026-01-00) funding the Center for Research and Education on Accessible Technologyand Experiences (CREATE). NIDILRR is a Center within the Administration for Community Living (ACL), Department of Health and Human Services (HHS). The contents of this article do not necessarily represent the policy of NIDILRR, ACL, HHS, and you should not assume endorsement by the Federal Government. We thank members of the Make4All lab and visualization system seminar at the University of Washington for their valuable feedback.

Metadata

Release files for matplotalt 0.0.7

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

Built distribution (wheel)

Table of built distributions (wheels) for matplotalt 0.0.7
File Interpreter ABI Platform Actions
matplotalt-0.0.7-py3-none-any.whl Python 3 none any Details for matplotalt-0.0.7-py3-none-any.whl

Release files / matplotalt-0.0.7-py3-none-any.whl

Download URL matplotalt-0.0.7-py3-none-any.whl
Size 38.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e29459bcb46e9f5aadad0ee4ca28c8f57869c03491f7137c4f32bd949f2f641b
BLAKE2b-256 checksum
How to use checksums
6de1185f8aa9f1cf6acad4e103f6cc79afb105c5af40f34958f035a36b79af86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Security for matplotalt 0.0.7

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